newsList:[188, 187, 190, 191, 192, 193, 194, 189, 195, 196, 198]
mounted() {
this.init();
this.action()
},
//開始
action(){
let promiseArr = this.newsList.map((item) => {
return this.getInfo(item)
})
Promise.all(promiseArr).then(value=>{
this.newsList = value;
console.log(this.newsList)
})
},
//測試
getInfo(item){
return new Promise((resolve,reject) => {
axios.get('https://uatapi.rock.tech/odakyuLayer2Category',{params:{
categoryID:item
}}).then(res=>{
console.log(res.data.Data)
let mydata = res.data.Data;
resolve({mydata:mydata})
})
})
},
Promise.all遍历接口
最新推荐文章于 2024-08-02 10:22:22 发布