下面直接上 代码
。
methods:{
geta(){
return new Promise((resolve, reject) => {
axios.post(url)
.then(response => {
resolve(response)
})
.catch(error => {
reject(err)
});
});
},
getb(){
return new Promise((resolve, reject) => {
axios.post(url)
.then(response => {
resolve(response)
})
.catch(error => {
reject(err)
});
});
},
getAll(){
// 调用Promise.all().then(res=>{})
Promise.all([this.geta(), this.getb()]).then((res) => {
console.log(res) //[{},{}]
}).catch(err => {
});
}
}