来源于:阿贤博客
17 行代码了解异步:Promise、await、async、setTimeout
async function one() {
let time = ()=>{
return new Promise((resolve, reject) => {
setTimeout(()=>{
console.log(1);
resolve(2);
}, 1000);
});
};
await time();
console.log(2);
}
let two = ()=>{
console.log(3);
}
await one();
two();
来源于:阿贤博客