async await执行结束后,希望.then中的方法也一并执行完毕,再跳出方法,要如何操作?-灵析社区

0offer糕手

父组件用 forEach 调用子组件的异步方法,会同时运行,并且不会等待。你需要用 map 返回一个promise的列表,然后再等待异步完成。 const initPromises = this.identifyFailed.map(async (alarm: Alarm, index: number) => { await this.$nextTick() returen await this.$refs['slideImageFaildRef'][index].initFilePath(alarm.id) }) Promise.all(initPromises).then(....)

阅读量:1

点赞量:0

问AI