1
noe132 2022-04-08 21:09:30 +08:00 1
async 函数的返回值就是 Promise
await 等同于 Promise.then “The async and await keywords enable asynchronous, promise-based behavior to be written in a cleaner style, avoiding the need to explicitly configure promise chains.” https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function#return_value 你要的函数: const sleepWith = (value, time) => new Promise(rs => setTimeout(() => rs(value), time)) |
2
Sunzehui 2022-04-09 06:29:20 +08:00
你可以在 nodejs 写个传入多少延时参数 sleep 后就 return 的 API ,前端 fetch 调用不用导入 jquery
或者自己实现一个任务队列 |