参考资料 https://www.jianshu.com/p/960571352bef
参考资料 https://www.jianshu.com/p/f369358803fd
同时进行多个请求,并统一处理返回值;
两步:
1,axios.all([]).then()
2,axios.spread()
methods: { getAllTask() { return axios.get('/data.json', { params: { id: 10 } }) }, getAllCity() { return axios.get('/city.json', { params: { id: 11 } }) } }, mounted() { axios.all([this.getAllTask(), this.getAllCity()]) .then(axios.spread(function(allTask, allCity) { console.log('请求1结果', allTask) console.log('请求2结果', allCity) })) },