带 axios 的进度条 [英] Progress Bar with axios
问题描述
我必须使用进度条显示文件的上传状态.我正在使用 axios
发出 http 请求.我从他们的 github 页面https://github.com/mzabriskie/axios/blob/master/examples/upload/index.html
I have to display the upload status of the file using a Progress Bar. I am using axios
to make http requests. I followed the example from their github page https://github.com/mzabriskie/axios/blob/master/examples/upload/index.html
我的代码如下:
this.store().then(() => {
var form = new FormData();
form.append('video', this.file);
form.append('uid', this.uid);
axios.post('/upload', form, {
progress: (progressEvent) => {
if (progressEvent.lengthComputable) {
console.log(progressEvent.loaded + ' ' + progressEvent.total);
this.updateProgressBarValue(progressEvent);
}
}
})
});
然而,它根本没有执行console.log(progressEvent.loaded + ' ' + progressEvent.total);
,也没有调用this.updateProgressBarValue(progressEvent);代码>
However, it is not executing the console.log(progressEvent.loaded + ' ' + progressEvent.total);
at all nor is it calling this.updateProgressBarValue(progressEvent);
我该如何解决这个问题??
How can I solve this??
推荐答案
我找到了答案.事件的名称是 onUploadProgress
,我使用的是 progress
I found the answer. The name of the event is onUploadProgress
and I was using progress
这篇关于带 axios 的进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!