如何在创建模式上重置表单验证?

How to reset the form validation on a create modal?

我不确定在这种情况下我应该做什么。当我点击 + Rule 时,我调用这个 fn()

showAddRuleModal() {
    this.showAddRule = true

    this.$refs.form.reset()

    //reset form values
    this.ruleName = ''
    this.url = 'https://www.'
    this.urlType = 'Single'

    this.ruleDetails = []

    let ruleDetail = {
        attribute_id: '',
        operator_id: '',
        value: ''
    }

    this.ruleDetails.push(ruleDetail)
}

如图所示,我成功创建了一个规则,并尝试添加一个。

如您所见,其他值似乎已重置,但我的 ruleName 输入被检测为错误,即使我重置 this.$refs.form.reset()

我怎样才能阻止它?


备注

如果我在默认值上加一个space

this.ruleName = ' '

那个错误消失了,但是现在,我的表单 ruleName 包含一个 space。 可以,但不是很好。

打开模式后使用:

this.$refs.form.resetValidation()

这应该会重置验证。 documentation example