美文网首页
前端代码睡一下

前端代码睡一下

作者: Phoenixing | 来源:发表于2023-09-14 15:55 被阅读0次

前端实现暂停执行,睡一下

const test = async () => {
  console.log(111111, +new Date())
  const sleep = (ms = 400) => new Promise(resolve => setTimeout(resolve, ms))
  await sleep(2000)
  console.log(222222, +new Date())
}

test()

相关文章

网友评论

      本文标题:前端代码睡一下

      本文链接:https://www.haomeiwen.com/subject/mtimvdtx.html