前端实现暂停执行,睡一下
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()
前端实现暂停执行,睡一下
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()