# JS 如何实现一个 sleep/delay 函数

Issue

欢迎在 Issue 中交流与讨论: Issue 442 (opens new window)

Author

回答者: yuuk (opens new window)

function delay(time) {
    return new Promise((resolve)=> {
        setTimeout(() => {
            resolve()
        }, time)
    })
}
Last Updated: 2/24/2021, 8:56:13 AM