分片上传时如何正确显示上传进度条?
我在做文件分片上传,每个分片用 axios 发送,但进度条总是跳变不平滑,不知道该怎么合并各分片的进度来更新整体进度?
试过在每个请求的 onUploadProgress 里累加 progress,但总大小算不准,导致进度条要么卡住要么直接到100%。下面是我用来显示进度条的样式:
.upload-progress {
width: 100%;
height: 8px;
background: #eee;
border-radius: 4px;
overflow: hidden;
}
.upload-progress .bar {
height: 100%;
background: #4caf50;
width: 0%;
transition: width 0.2s ease;
}
有没有人遇到过类似问题?怎么准确计算总进度啊?
暂无解答