el-upload使用http-request覆盖默认上传行为调出默认的进度条

        <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  //调用默认的进度条
}

 

posted @ 2020-09-10 12:32  银耳钉  阅读(3181)  评论(0编辑  收藏  举报