REACT-多个下载的单个进度栏
我想同时下载文件,但我想获得进度 单个进度栏中的下载。
我已经有了下载资产的代码,只需要最好的方法来表示它即可。
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',
}
}))
编辑:
接受的答案对我有所帮助,现在我有了一个进度标准,同时下载的百分比
I want to download files simultaneously, but I want to get the progress
of the download in a single progress bar.
I already have the code to download the assets, just need the best way to represent it.
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',
}
}))
Edit:
The accepted answear helped me and now I have a progress bar with the percentage of all downloads simultaneously
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一番挖掘,我发现了以下内容:
ps:这是一个快速解决方案。
资源
After a little bit of digging, I found this:
P.S: This is a quick solution.
Resources