英文:
vee: validate with required fails when setting checkbox value programmatically
问题
这个链接: https://codesandbox.io/s/jovial-glade-tg7ev
当点击a、b或c复选框时,ValidationObserver会起作用。但是当通过程序将值插入数组(点击按钮)时,ValidationObserver无法检测到它。这是一个错误吗?我认为ValidationObserver的valid属性应该改变。
Ken
英文:
This: https://codesandbox.io/s/jovial-glade-tg7ev
ValidationObserver works when clicking a, b or c checkbox. But when value is inserted in array programmatically (click button), the ValidattionObserver doesn't detect it. Is that an error and I think the valid property from ValidationObserver should change?
Ken
答案1
得分: 0
为了测试在以编程方式设置值时的验证,您需要在更新值之后立即调用以下代码片段,并在ValidationObserver
组件上添加ref="observer"
。
this.$refs.observer.validate();
更新后的 CodeSandbox:https://codesandbox.io/s/summer-pine-mrrlm
英文:
To test the validation when setting the values programatically, you have to call the following piece of code, just after you've updated the value, and put a ref="observer"
on the ValidationObserver
component.
this.$refs.observer.validate();
Updated codesandbox: https://codesandbox.io/s/summer-pine-mrrlm
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论