AI智能
改变未来

await async相关

每隔几秒输出值

function sleep(interval) {return new Promise(resolve => {setTimeout(resolve, interval);})}// 用法async function one2FiveInAsync() {for(let i = 1; i <= 5; i++) {console.log(i);await sleep(1000*i);}}one2FiveInAsync();

https://www.jianshu.com/p/1c9e9c161612

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » await async相关