Promise.all ()
可以使用Promise.all 封裝多個(gè)請(qǐng)求,這時(shí)候返回的數(shù)據(jù)會(huì)封裝成數(shù)組,在使用[...參數(shù)1, ...參數(shù)2]
合并成一個(gè)數(shù)組對(duì)象
Promise.all([
getDetailListApi({
currentPage: 1,
pageSize: 1000,
parentId: 2,
token: localStorage.getItem("token")
}),
getDetailListApi({
currentPage: 1,
pageSize: 1000,
parentId: 16,
token: localStorage.getItem("token")
})
]).then(res => {
if (res[0].success == true && res[1].success == true) {
this.sourceArr = [...res[0].data.list, ...res[1].data.list];
}
});