vee: 在以编程方式设置复选框值时,使用必填项验证失败

huangapple go评论64阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年1月6日 22:18:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/59613702.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定