jdf2e / nutui

京东风格的移动端 Vue 组件库,支持多端小程序(A Vue.js UI Toolkit for Mobile Web)
https://nutui.jd.com
MIT License
6.17k stars 835 forks source link

form表单验证问题,多选组件绑定的是数组完全不会检验 #3160

Open shitou158 opened 3 months ago

shitou158 commented 3 months ago

NutUI 包名

@nutui/nutui-taro

NutUI 版本号

4.3.12

平台

h5

重现链接

https://nutui.jd.com/playground/#eyJBcHAudnVlIjoiPHRlbXBsYXRlPlxuICA8bnV0LWZvcm0gcmVmPVwiZm9ybVJlZlwiIDptb2RlbC12YWx1ZT1cImZvcm1EYXRhXCI+XG4gICAgPG51dC1mb3JtLWl0ZW0gbGFiZWw9XCLlp5PlkI1cIiBwcm9wPVwibmFtZVwiIHJlcXVpcmVkIDpydWxlcz1cIlt7IHJlcXVpcmVkOiB0cnVlLCBtZXNzYWdlOiAn6K+35aGr5YaZ5aeT5ZCNJyB9XVwiPlxuICAgICAgPG51dC1jaGVja2JveC1ncm91cCB2LW1vZGVsPVwiZm9ybURhdGEubmFtZVwiPlxuICAgICAgPG51dC1jaGVja2JveCBsYWJlbD1cIjFcIj4gQSA8L251dC1jaGVja2JveD5cbiAgICAgIDxudXQtY2hlY2tib3ggbGFiZWw9XCIyXCI+IEIgPC9udXQtY2hlY2tib3g+XG4gICAgICA8bnV0LWNoZWNrYm94IGxhYmVsPVwiM1wiPiBDIDwvbnV0LWNoZWNrYm94PlxuICAgICAgPG51dC1jaGVja2JveCBsYWJlbD1cIjRcIj4gRCA8L251dC1jaGVja2JveD5cbiAgICA8L251dC1jaGVja2JveC1ncm91cD5cbiAgICA8L251dC1mb3JtLWl0ZW0+XG4gICAgXG4gICAgPG51dC1zcGFjZSBzdHlsZT1cIm1hcmdpbjogMTBweFwiPlxuICAgICAgPG51dC1idXR0b24gc2l6ZT1cInNtYWxsXCIgdHlwZT1cInByaW1hcnlcIiBAY2xpY2s9XCJzdWJtaXRcIj7mj5DkuqQ8L251dC1idXR0b24+XG4gICAgICA8bnV0LWJ1dHRvbiBzaXplPVwic21hbGxcIiBAY2xpY2s9XCJyZXNldFwiPumHjee9ruaPkOekuueKtuaAgTwvbnV0LWJ1dHRvbj5cbiAgICA8L251dC1zcGFjZT5cbiAgPC9udXQtZm9ybT5cbjwvdGVtcGxhdGU+XG5cbjxzY3JpcHQgc2V0dXA+XG5pbXBvcnQgeyByZWYgfSBmcm9tICd2dWUnXG5jb25zdCBmb3JtRGF0YSA9IHJlZih7XG4gIG5hbWU6IFtdLFxuICB0ZWxzOiBbXVxufSlcbmNvbnN0IGZvcm1SZWYgPSByZWYobnVsbClcblxuY29uc3QgcmVtb3ZlID0gKCkgPT4ge1xuICBmb3JtRGF0YS52YWx1ZS50ZWxzLnBvcCgpXG59XG5cbmNvbnN0IHN1Ym1pdCA9ICgpID0+IHtcbiAgZm9ybVJlZi52YWx1ZT8udmFsaWRhdGUoKS50aGVuKCh7IHZhbGlkLCBlcnJvcnMgfSkgPT4ge1xuICAgY29uc29sZS5sb2codmFsaWQpXG4gICAgaWYgKHZhbGlkKSB7XG4gICAgICBjb25zb2xlLmxvZygnc3VjY2VzczonLCBmb3JtRGF0YS52YWx1ZSlcbiAgICB9IGVsc2Uge1xuICAgICAgY29uc29sZS53YXJuKCdlcnJvcjonLCBlcnJvcnMpXG4gICAgfVxuICB9KVxufVxuXG5jb25zdCByZXNldCA9ICgpID0+IHtcbiAgZm9ybVJlZi52YWx1ZT8ucmVzZXQoKVxufVxuPC9zY3JpcHQ+XG4ifQ==

重现步骤

如果是多选的组件,多选组件绑定值是数组,这时候的校验完全不生效,选不选都没校验了 valid一直是true

期望的结果是什么?

如果是多选的组件,多选组件绑定值是数组,校验也生效

实际的结果是什么?

如果是多选的组件,多选组件绑定值是数组,校验没生效

环境信息

No response

其他补充信息

No response

shitou158 commented 3 months ago

@eiinu 大佬,目前有没有什么应急的方法,现在只有绑定是字符串才会验证,但是给checkboxGroup的vmodel绑定字符串会报错