0

这个例子展示了一个用 vue-formulate 制作的非常小的表单:

https://codesandbox.io/s/vue-formulate-reseting-form-does-not-initiate-validation-message-again-yxruq

输入字段采用至少 4 个字符的字符串。点击提交后,表单通过重置

this.$formulate.reset(‘[name-of-the-form]‘)

它确实清除了表格。但验证消息不再出现。

必须做些什么来解决这个问题?或者这可能是一个错误?

4

1 回答 1

1

看起来该$formulate.resetValidation()方法有点过于激进,具体取决于分配的验证行为。您可以通过将 ref 应用于表单,然后显式迭代注册表来“撤消”此操作:

<FormulateForm
  ...
  ref="form"
>
// in your submit handler:
this.$refs.form.registry.map((input) => {
  input.formShouldShowErrors = true;
})

更新复制:https ://codesandbox.io/s/vue-formulate-reseting-form-does-not-initiate-validation-message-again-forked-kn12h?file=/src/components/Reproduction.vue

于 2021-12-28T21:05:48.887 回答