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