[vue] 如果将axios异步请求同步化处理?
async ,await
// 统一处理axios请求
async getHistoryData (data) {
try {
let res = await axios.get('/api/survey/list/', {
params: data
})
this.tableData = res.data.result
this.totalData = res.data.count
} catch (err) {
console.log(err)
alert('请求出错!')
}
}
}
async ,await
Generator函数
回调里面写回调
Most helpful comment