本文仅记录在select使用过程中出现的不常见问题,一般的使用问题,请直接在官网查看。
1,有时后端使用的数据是int类型,也就是说,你要绑定的value是数字,使用官网上的验证方法是无法通过检测的,这个时候怎么办呢?官网上使用的验证规则是 async-validator,该规则中rule的type是这样定义的string: Must be of type string. This is the default type.
,因此,按照官网上的写法{ required: true, message: 'Please select the city', trigger: 'change' }
,实际上完整的验证应该是{ required: true, message: 'Please select the city', trigger: 'change',type:'string' }
,因此当我们选中value是数字1
的时候,因为类型不对,故而检测不通过。说到这里,你应该已经知道了怎么修改了,{ required: true, message: 'Please select the city', trigger: 'change',type:'number' }
iview组件之select绑定类型number
最新推荐文章于 2023-07-03 16:46:19 发布