仅作笔记用:JS 一行代码实现同步的延时语句 Posted on 2023-09-03 00:00:00 In JavaScript 就是这一句代码 1await new Promise(resolve => setTimeout(resolve, 2000)); 最后的数字就是延时时长 示例 12345(async function() {console.log("延时开始");await new Promise(resolve => setTimeout(resolve, 2000));console.log("延时结束");})(); 效果 Buy me a coffee Donate Alipay