Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问上传图片有表单验证吗 #10

Closed
williamBoss opened this issue May 24, 2018 · 16 comments
Closed

请问上传图片有表单验证吗 #10

williamBoss opened this issue May 24, 2018 · 16 comments
Labels
bug Something isn't working

Comments

@williamBoss
Copy link

请问上传图片有表单验证吗

@xaboy
Copy link
Owner

xaboy commented May 24, 2018

上传图片没有表单验证,你想验证什么?

@williamBoss
Copy link
Author

就是验证必须上传

@williamBoss
Copy link
Author

validate : [ {
required : required,
message : "请上传" + title,
trigger : 'blur'
} ]

@williamBoss
Copy link
Author

我这样写的,但是上传之后依旧要我上传图片,验证没有通过

@xaboy
Copy link
Owner

xaboy commented May 24, 2018

上传组件的验证确实存在问题,这个问题下个版本会修复。目前不建议的上传组件中使用验证

@williamBoss
Copy link
Author

请问可以有展示替代的办法吗

@xaboy
Copy link
Owner

xaboy commented May 24, 2018

可以在表单提交的时候单独判断一下,这样确实比较笨拙。抱歉,下个版本一定修复。

onSubmit:()=>{
//maxLength= 1 value为String
    if(!$f.getValue('uploadField')){
        //TODO 没有上传图片
        return false;
    }
//maxLength > 1 value为Array
    if(!$f.getValue('uploadField').length){
         //TODO 没有上传图片
        return false;
    }
}

@williamBoss
Copy link
Author

非常感谢

@xaboy xaboy added the bug Something isn't working label May 24, 2018
@williamBoss
Copy link
Author

validateField(field,callback) 请问是否可以使用这个方法替代呢

@xaboy
Copy link
Owner

xaboy commented May 24, 2018

不行,这个还是根据validate规则验证的

@williamBoss
Copy link
Author

好的,明白了,谢谢

@williamBoss
Copy link
Author

trigger 请问一下,这个参数是做什么的

@williamBoss
Copy link
Author

williamBoss commented May 24, 2018

{ required: true,type:'array', message: '请选择标签', trigger: 'change' }请问其中的type:‘array’在哪些类型会用到

@xaboy
Copy link
Owner

xaboy commented May 24, 2018

是触发验证的方式
详细参考这里https://github.com/yiminghe/async-validator

@williamBoss
Copy link
Author

谢谢

@xaboy
Copy link
Owner

xaboy commented May 27, 2018

1.2.2 办法已发布,已修复上传组件验证问题

@xaboy xaboy closed this as completed May 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants