【发布时间】:2020-05-09 22:34:24
【问题描述】:
我有一些代码,await-s 设置如下:
async calculateDeletionResidualsData(res) {
//console.log("resss is:");
//console.log(res);
let selectedCountries = this.countriesList.filter(c => c.selected);
let selectedIndicators = this.indicatorsList.filter(i => i.selected);
await selectedCountries.forEach(async c => {
// taking each (selected) country
await selectedIndicators.forEach(async i => {
// taking each (selected) indicator
// Form the series for the calculation of residuals
let series = [];
deletionResidualsRelevantYears.forEach(y => {
series.push(res[c.label][y][i.label][0]);
});
// Calculate deletion residuals
let drr = await util.calculateDeletionResidualsStatistics(
deletionResidualsRelevantYears.length,
series,
this.deletionResidualsService
);
this.drr[c.label][i.label] = drr;
});
});
console.log("setting qrReady to true");
this.qrReady = true;
}
我可以清楚地看到对util.calculateDeletionResidualsStatistics 的调用仍在我浏览器的网络选项卡中进行,但我也看到console.log("setting qrReady to true"); 已经被触发,不应该被触发。为什么所有这些等待都被跳过并跳到最后一行代码?
【问题讨论】:
标签: angular promise async-await