猿问

element-ui 的upload组件,before-upload验证不通过后为什么会触发了on-remove的执行?

"vue":"^2.5.2","element-ui":"^2.2.1",
action="http://mt.cn:3355/backend/config/uploadImg"
list-type="picture-card"
:file-list="themePictures"
:data="themeData"
:on-success="themeSuccess"
:on-remove.self="removeTheme"
:on-error="uploadError"
:before-upload="beforeUpload">
removeTheme(file,fileList){
req_removeTheme({id:file.id}).then(res=>{
this.$message.success('删除成功')
})
},
beforeUpload(file){
constisMatch=file.type==='image/jpeg'||file.type==='image/jpg'||file.type==='image/png'||file.type==='image/gif'||file.type==='image/bmp'
constisLt2M=file.size/1024/1024<1
if(!isMatch){
this.$message.error('图片格式不匹配')
}
if(!isLt2M){
this.$message.error('上传头像图片大小不能超过1MB!')
}
returnisMatch&&isLt2M
},
30秒到达战场
浏览 739回答 2
2回答

婷婷同学_

好像新的才会出现这个问题,试了下可以通过file.status的状态来区分`handleRemove(file,fileList){if(file&&file.status==="success"){//删除}}`
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答