1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > node.js async await 配合Promise对象使用

node.js async await 配合Promise对象使用

时间:2020-04-02 01:42:14

相关推荐

node.js async await 配合Promise对象使用

function getData(){return new Promise(function(resolve, reject){setTimeout(function(){var uname = 'zhang';console.log('this is timeout');resolve(uname);}, 1000);});}//await 配合 promiese 的 resolve 使用 就会真的等待 同步async function test(){console.log(1);var t = await getData();console.log(t);console.log(3);}test();console.log('xxx');

1xxxthis is timeoutzhang3

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。