el-upload 文件上傳失敗時標紅顯示,且文件名拼接上(上傳失敗)


    <el-upload          
     accept=".doc,.pdf"
      ref="upload"
      :show-file-list="true"
      :headers='uploadHeaders'
      :action="uploadUrl"          
      :on-success="onSuccess"         
      :fileList="flieList">
          <el-button type="primary">點擊上傳</el-button>
    </el-upload>
   

在el-upload 的綁定的on-success方法寫,方法在vue的methods里面

onSuccess(res,file,fileList){
    if(res.success){//根據自己項目的上傳文件返回值判斷
       this.fileList=fileList
   }else{
       file.status='error'
       file.name=`${file.name}(上傳失敗)`
       this.fileList=fileList
   }
}

然后重寫上傳狀態是error的字體顏色
  
/deep/ li.el-upload-list__item.is-error{
    .el-upload-list__item-name{
       color:red !important;
    }
}

  


免責聲明!

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



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