直接貼代碼了,自己去打印看效果就會懂
async function async1() {
console.log(1);
const result = await async2();
async3()
}
async function async2() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(2)
console.log(2)
}, 2000);
})
}
function async3() {
console.log(3)
}
async1();
喜歡上方小程序,需要源碼的,私信小編留下郵箱。