(async () => {
await this.getInLotteryAmount()
await this.getUser()
await this.createNormalChatroom()
await console.log('1-1')
})()
new Promise((resolve, reject) => {
// this.getInLotteryAmount()
console.log('11--')
}).then(() => {
console.log('22--')
this.getUser()
}).then(() => {
console.log('33--')
this.createNormalChatroom()
console.log('1-1')
}).catch((err) => {
console.log('catch--')
})
以上两种写法有问题吗?async那个回调顺序不对,promise那个直接卡住了,不走下一个then.
上面这段代码,应该是严格按照 1》2》3》4 执行的,你说的回调顺序不对,这里看不到代码不晓得你说的什么意思
第二段代码
因为不晓得你3个函数的内部实现,以下是我模拟的示例代码,希望你有帮助