您的位置:首页 > 大数据 > 人工智能

async/await来处理异步

2018-11-11 15:40 633 查看
[code]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);// 两秒之后会被打印出来
}

 

阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: