onSearch() {
var that = this
// 获取城市code
const city = sessionStorage.getItem('departCity')
const citys = window.cityMap.get(city) // 获取城市对象
// 存储所有http请求
const reqList = []
// 存储后台响应每个请求后的返回结果
const resList = []
for (let i = 0; i < citys.children.length; i++) {
var areaCode = citys.children[i].id
const req = axios.get(process.env.BASE_API + '/api/rescure/sign/receive/rescureSignStatisticalList?areaCode=' + areaCode)
reqList.push(req)
resList.push(('post' + (i + 1)).replace(/[']+/g, ''))
}
return axios.all(reqList).then(axios.spread(function(...resList) {
for (let i = 0; i < resList.length; i++) {
// that.tableData全局变量-数组
that.tableData.push(resList[i].data.result[0])
}
// return resList
}))
},
citys对象
参考链接
添加链接描述 参考简书