function sleep(sec) { return new Promise((resolve,reject)=>{ setTimeout(resolve,sec); }) } async function fun1() { await sleep(1000).then(()=>{ console.log("黄灯一秒") }) } while(1) { fun1(); }