test: function() {
console.log(1)
this.test1().then(res => {
setTimeout(function() {
console.log(3)
}, 2000)})
},
test1: function() {
return new Promise((resolve, reject) => {
setTimeout(function() {
console.log(2)
resolve('suc');
}, 2000)
})
}
搞不懂加上 async 和 await 和不加一样的运行顺序
test: async function() {
console.log(1)
await this.test1().then(res => {
setTimeout(function(){
console.log(3)
},2000)
})
},
test1: function() {
return new Promise((resolve, reject) => {
setTimeout(function(){
console.log(2)
resolve('suc');
},2000)
})
}