created () { this.init()
},
methods: {
init () { this.getToken() this.getData()
}, async getToken () { let token = await postToken()
...
}, async getData () { if(this.token) return 'token no null'
let data = await postData();
....
}
}代碼大致如上,實際運行時總是報'token no null',不是已經給兩個用到ajax方法加async await了嗎,為什么還是異步?
js 關于async await的問題?
慕俠2389804
2018-07-21 22:06:54