首页 > Web开发 > 详细

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

时间:2020-09-10 13:04:11      阅读:922      评论:0      收藏:0      [点我收藏+]
        <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  //调用默认的进度条
}

 

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

原文:https://www.cnblogs.com/yinerding/p/13644971.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!