function setTimeFun() {
return new Promise((resolve, rejects) => {
setTimeout(() => {
console.log(3)
resolve()
}, 3000)
})
}
async function testFun() {
console.log(1)
await setTimeFun()
console.log(2) // 等输出3秒后输出3才会执行
}
testFun()
网友评论