js:
doList(){
let array = []
for (let i = 0; i < storageNum; i++) {
array = array.concat(this.toPromise(i))
}
Promise.all(array).then((res) => {
console.log(res) // [ 0, 1, 2 ]
})
},
toPromise(num) {
return new Promise((resolve, reject) => {
resolve(‘成功了’+num);
//请求操作
// this.axios.get(‘http://test.fastadmin.cn/index.php/api/index/test’,{}).then(res => {}).catch(err => {});
})
},
vue并发,同时请求多个
最新推荐文章于 2024-05-17 14:46:37 发布