async function executeWithDelay() {
console.log("开始");
await sleep(2500); // 等待 2.5 秒
console.log("2.5 秒后执行的代码");
}
executeWithDelay();
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
暂无评论