阅读:2645回复:0
async await执行顺序问题
async function async1(){
console.log('async1 start') //2 await async2() //3 console.log('async1 end') //8 } async function async2(){ console.log('async2') } console.log('script start') //最先一步 1 setTimeout(function(){ console.log('setTimeout') }, 0) //最后一步 9 async1() new Promise(resolve => { console.log('promise0') //4 resolve() }) .then(()=>{ console.log('promise1') //6 }) .then(()=>{ console.log('promise2') //7 }) console.log('script end') //5 输出结果: script start => async1 start => async2 => promise0 => script end => promise1 => promise2 => async1 end => setTimeout |
|