vuejs + element ui 做项目的时候。使用await new Promise 做弹窗确认,resolve和reject需要对应弹出窗口的点击和关闭事件,也就是resolve和reject都需要调用,否则await会一直等待,并且后面的代码不执行。
async changeState(event, scope) {
let confirm = false;
await new Promise((resolve, reject) => {
this.confirmDialogVisible = true;
this.confirmFunc = resolve;
// resolve();
}).then(
res => {
confirm = true;
console.log("===========1");
},
err => {
console.log("===========2");
}
);
console.log(confirm);
}