【发布时间】:2022-12-23 20:19:49
【问题描述】:
我想同时下载文件,但我想获得进度 下载在单个进度条中。
我已经有了下载资产的代码,只需要最好的方式来表示它。
Promise.all(arr.map((endpoint) => axiosInstance.get(endpoint.url,{
onDownloadProgress: (progressEvent) =>{
let percentCompleted = Math.round(progressEvent.loaded * 100 /
progressEvent.total);
console.log(progressEvent.lengthComputable);
console.log("progress completed : " + percentCompleted);
},
responseType:"arraybuffer",
headers: {
'Content-Type': 'application/json',
}
}))
编辑:
接受的回答对我有帮助,现在我有一个进度条,其中包含同时下载的百分比
【问题讨论】:
标签: reactjs react-hooks axios download progress-bar