async function hello(){
return 'hello world';
}
await 可以理解为是 async wait 的简写。await 必须出现在 async 函数内部,不能单独使用。
async function awaitDemo() {
await normalFunc();
console.log('something, ~~');
let result = await sleep(2000);
console.log(result);// 两秒之后会被打印出来
}
async/await来处理异步
猜你喜欢
转载自blog.csdn.net/qq_39313596/article/details/83959064
今日推荐
周排行