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();

浙公网安备 33010602011771号