function pro(){
return new Promise(resolve => {
setTimeout(() => {
resolve(console.log(new Date().getSeconds()))
}, 1000)
})
}
async function fot () {
for (let i=0;i<5;i++){
await pro()
console.log('i', i)
}
}
fot()
function pro(){
return new Promise(resolve => {
setTimeout(() => {
resolve(console.log(new Date().getSeconds()))
}, 1000)
})
}
async function fot () {
for (let i=0;i<5;i++){
await pro()
console.log('i', i)
}
}
fot()
本文标题:for循环中使用await
本文链接:https://www.haomeiwen.com/subject/rnpyaxtx.html
网友评论