methods: {
getAll() {
return new Promise((resolve, reject) => {
this.$axios.get(eventApi.getAllUsers).then(response => {
let a = response.data[0];
console.log(a);
resolve(a);
});
});
},
getlog() {
return new Promise((resolve, reject) => {
console.log("111");
resolve("111");
});
},
getLog2() {
console.log("222");
},
getlog3() {
setTimeout(() => {
console.log("333");
}, 100);
},
getlog4() {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log("444");
resolve();
}, 1000);
});
},
async getAllData() {
await this.getlog();
await this.getlog4();
await this.getAll();
await this.getlog3();
await this.getLog2();
}
想要await按照預(yù)期來執(zhí)行,就必須是promise
不理解的請(qǐng)留言啦辐!哈哈哈驾中,我會(huì)告訴你??