账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    element-ui 的upload组件,before-upload验证不通过后为什么会触发了on-remove的执行?
    43
    0

    "vue": "^2.5.2",
    "element-ui": "^2.2.1",

    <el-upload
        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">
        <i class="el-icon-plus"></i>
    </el-upload>
    removeTheme(file, fileList) {
        req_removeTheme({id:file.id}).then(res => {
            this.$message.success('删除成功')
        })
    },
    beforeUpload(file) {
        const isMatch = file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png' || file.type === 'image/gif' || file.type === 'image/bmp'
        const isLt2M = file.size / 1024 / 1024 < 1
    
        if (!isMatch) {
            this.$message.error('图片格式不匹配')
        }
        if (!isLt2M) {
            this.$message.error('上传头像图片大小不能超过 1MB!')
        }
        return isMatch && isLt2M
    },
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部