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  //調用默認的進度條
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM