シーン:複数の、無関係な要求からのデータのページは、必要と統一された治療法を提示しました。
Axiosは、APIのペアを使用する必要があります。
1.axios.all(反復処理可能)
2.axios.spread(コールバック)
- .axios.all(iterable)
- 参数: 请求数组
- axios.spread(callback)
- 参数: 对应请求返回值
axios.all(
[
axios.get('/test1'),
axios.get('/test2')
]
).then(
axios.spread( (test1Res,test2Res) => {
console.log(test1Res,test2Res)
})
)