mounted () {
let list = [1, 2, 3]
let queue = list.map(item => {
return new Promise(resolve => {
this.$axios.get('ycxflzws/lzWebService.asmx/schphonebycommunityname',
{
params: {
'communityname': '浙江华数广电网络'
}
}).then((res) => {
console.log(res)
if(res.data.data.code===0){
resolve(res.status)
}
else{
resolve('error')
}
})
})
})
Promise.all(queue).then(result => {
console.log(result)
}).catch(reason => {
console.log('promise reject failed reason', reason)
})
}
promise.all .then .catch
最新推荐文章于 2025-05-27 08:30:00 发布
该博客内容展示了如何在Vue应用中使用Promise.all处理多个并发的axios请求。代码示例中,通过map函数创建了一个请求队列,每个请求从'ycxflzws/lzWebService.asmx/schphonebycommunityname'获取数据,并根据响应数据的code字段决定Promise的解决状态。
844

被折叠的 条评论
为什么被折叠?



