假前端今日份收获:
(async ()=> {
const test2=async()=>{
return Promise.reject()
}
const test1=async()=>{
console.log(1) // 只会输出1,不会输出3
await test2()
console.log(3)
}
const test3=async()=>{
await test1() // 如果不使用await,会输出4
console.log(4)
}

try {
await test3()
console.log(5) // 在try中console不会执行
} catch (err){}

console.log(6) // 会执行

})()
展开
评论