axios 并发请求
参考资料 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) })) },
本文来自博客园,作者:秋风2016,转载请注明原文链接:https://www.cnblogs.com/lml2017/p/13470782.html