Promise.all()方法在项目中的应用
<script>
const handleData = async () => {
let picSrcArr = [];
res.data.forEach((item) => {
let promiseItem = new Promise(async resolve => {
let params = {
storeName: item.logo
};
const res = await api.handleFile.fileDownload({ params });
return resolve(res);
});
picSrcArr.push(promiseItem);
});
Promise.all(picSrcArr).then(result => {
result.forEach((item, index) => {
res.data[index].logo = window.URL.createObjectURL(item);
res.data[index]['enabled'] = true;
});
myAppList.value = res.data || [];
});
};
</script>