func1();
async function func1() {
for (let i = 1;i<=5;i++){
let x = await sleep();
console.log(x);
}
}
function sleep(){
return new Promise((resolve, reject)=> {
setTimeout(()=>{
resolve("1333")
}, 3000)
})
}
js实现sleep函数,在循环中延迟执行
最新推荐文章于 2023-12-23 11:10:26 发布