Angular 控制台日志未定义
此处未定义控制台日志Angular 控制台日志未定义,angular,Angular,此处未定义控制台日志 this.http.get(this.rootURL + "/Report/"+id) .toPromise().then(res => this.report = res as Report); console.log(this.report); } 这里是控制台日志数据 this.http.get(this.rootURL + "/Report/"+id) .toPromise().then(r
this.http.get(this.rootURL + "/Report/"+id)
.toPromise().then(res => this.report = res as Report);
console.log(this.report);
}
这里是控制台日志数据
this.http.get(this.rootURL + "/Report/"+id)
.toPromise().then(res => console.log(res));
console.log(this.report);
}
如何将结果分配给结果对象将数据记录在 你在用wait吗 你应该这样做:
const main=async()=>{
等待this.http.get(this.rootURL+“/Report/”+id).toPromise()。然后(data=>{
控制台日志(数据);
})
}
您需要在回调中执行其他操作,然后
回调,或者使用async/await.maybe高级复制
this.http.get(this.rootURL + "/Report/"+id)
.toPromise()
.then(res => {
// Promise gets fulfilled and its response can be assigned
this.report = res as Report;
console.log(this.report);
// Perform other actions
// ...
})
.catch(reason => {
// Something went wrong, your promise gets rejected
console.log(reason);
});