<el-upload
accept=".doc,.pdf"
ref="upload"
:show-file-list="true"
:action="void"
:http-request="upLoadOnSelf"
:on-progress="uploadOnProgress"
:fileList="flieList">
<el-button type="primary">点击上传</el-button>
</el-upload>
</div>
然后method里面的方法
upLoadOnSelf(fileParam){
const fileObj =fileParam.file;
const form = new FormData();
form.append("file", fileObj);
this.$http.post(`/file/upload`, form,
{onUploadprogress:function(event){
percent = event.loaded/event.total*100
fileParam.onProgress({percent:percent })
}
}).then(res={//处理成功情况
fileParam.onSuccess()//显示完成按钮小图标
...//其它处理
})
},
uploadOnProgress(event,file,fileList){
this.progress=event.perecent //调用默认的进度条
}