标签:timeout ret pre nbsp res span art await start
var sleep = function (time) { return new Promise(function (resolve, reject) { setTimeout(function () { //此处执行异步操作 resolve(‘ok‘); }, time); }); }; var start = async function () { try{ console.log(‘start‘); var result = await sleep(1000); console.log(result); console.log(‘end‘); }catch(err){ console.log(err); } }; start();
标签:timeout ret pre nbsp res span art await start
原文地址:http://www.cnblogs.com/wanghaonull/p/6846096.html