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