function getUserAccount() {return axios.get(\'http://localhost:8080/pingg?name=12345&sex=nan\');}function getUserPermissions() {return axios.get(\'http://localhost:8080/pingg1?name=23423&sex=ssfsfs\');}axios.all([getUserAccount(), getUserPermissions()]).then(axios.spread(function (acct, perms) {console.info(acct.data,perms.data)}));
Axios.spread中的函数,请求全部完成后会调用,并且请求数据会一一对应参数。
发送的请求数不确定时,使用map结合Axios.all
Axios.all(arr.map(function (data)=>{return this.axios.post(....)})).then(Axios.spread((...a) => {console.log(\'全部加载完成\')})).catch(err => {console.log(err.response)});