function delay(ms) { return new Promise((resolve, reject) => setTimeout(resolve, ms)) } let init =async()=>{ console.log(1) await delay(2000) console.log(2) } init() 作者:北京小伙_盼 链接:https://juejin.cn/post/7138662664883929096 来源:稀土掘金 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
标签:睡眠,resolve,console,log,js,delay,init,函数 From: https://www.cnblogs.com/hhcome/p/17434612.html