:::info ES7的新玩意,觉得promise还是在回调,弄了个这个加深了一下promise,很不错 :::
async function f(){
console.log(1)
let r = await new Promise(function (res) {
setTimeout(function () {
res(3)
}, 1000)
})
console.log(r)
console.log(4)
}
// 区域外依然是异步的
console.log(2)
// 1
// 2
// 3
// 4
//如果异步操作返回 1 4 2 3