JavaScript异步等待

function SLEEP(t) {
    return new Promise(function(resolve, reject) {
        setTimeout(() => {
            resolve();
        }, t)
    });
};

async function asyncFunc() {
    console.log(Date());
    await SLEEP(5000);
    console.log(Date());
};

asyncFunc();
posted @ 2025-05-12 01:47  (๑•_•๑)  阅读(18)  评论(0)    收藏  举报