直接贴代码了,自己去打印看效果就会懂
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();
喜欢上方小程序,需要源码的,私信小编留下邮箱。