场景:代码中需要按顺序调用异步方法
demo: 用async, await组合
async postFunc () {
for(let i = 0; i < this.List.length; i++) {
let data = {
ouId: this.List[i].ouId,
}
await postFuncAPI(data).then((res) => {
if (res.state === config.RES_CODE) {
// do something
} else {
// do something
}
})
}
this.$notify({
title: '批量操作结果',
dangerouslyUseHTMLString: true,
message: `批量操作成功`
duration: 5000
});
}