1、在异步最近的方法上加入 async
async fileLoad() {
2、在异步方法上加入 await
await GetNextScriptID()
3 、demo
// 加入async
async fileLoad() {
for (let i = 0; i < this.$refs.refFile.files.length; i++) {
// 加入 await 第二个async
await GetNextScriptID().then( async r => {
temporary = { id: r };
//加入 await
await addScript(temporary).then(res => {});
});
}
}
网友评论