使用async await,await的函數(shù)log出了數(shù)據(jù),但是async函數(shù)獲取不到值,并且先打印出undefined,在打印出數(shù)據(jù) getRechargeOrder () {
let apiUrl = this.$api.URL.rechargeOrder this.$api.axiosGet(apiUrl, para).then(res => { if (res.data.code === 0) {
let data = res.data.data
if (data.payNum) {
console.log(data)//{payTotal: 3344, payNum: 86, payPeopleNum: 65, list: Array(86)}
return data
}
}
}).catch(error => alert('error'))
},
async getDau () {
let res = await this.getRechargeOrder()
console.log(res)//undefined
}
vue中使用async await遇到的問題
莫回?zé)o
2018-08-03 16:28:14