function delay(n) {
return new Promise(function(resolve) {
setTimeout(resolve, n * 1000);
});
}
async function myAsyncFunction() {
// Do what you want here
console.log('Before the delay')
await delay(5);
console.log('After the delay')
// Do what you want here too
}
myAsyncFunction();
利用 await 来实现同步等待
qvwvugkjut
你的文章让我感受到了快乐,每天都要来看一看。 https://www.4006400989.com/qyvideo/44180.html