多请求参数值更替拿值
处理接口取不同参数返回不同值,遍历调用接口返回多promise,最后使用promise.all[]同意处理拿到最终值
async getLineData() {
let lineDatas = this.querys.map(query => {
let obj = { name: query }
// 遍历参数数组返回promise数组
return new Promise((res,reject) => {
let queryData = this.$api.dev.listTables({ queryTable: query })
.then(r => {
obj.selectLineFiles = r.data
res(obj)
});
});
})
// 结合async await拿到返回值
let fileLineList = await Promise.all(lineDatas);
this.lineDataFeilds = fileLineList.map((p, i) => {
return {
names: { name: p.name},
selectLineFile: this.lineDataBaseDeal(p.selectLine)
}
})
},