async 用法
async function A() {
let a = await 1;
console.log(a);
let b= await Promise.resolve(2);
console.log(b);
return 3;
}
转码理解
function A() {
var a;
var b;
return new Promise(function(resolve){
a = 1;
console.log(a);
resolve();
}).then(function(){
Promise.resolve(2).then(res => {
b = 2;
console.log(b)
});
}).then(() => 3)
}
网友评论