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;
    }
}

  

posted @ 2020-09-15 17:28  银耳钉  阅读(2509)  评论(0编辑  收藏  举报