VeeValidate 验证不存在的字段错误,即使使用密钥也是如此



我一直在尝试让它工作一段时间,但我还没有找到解决方案。我已经阅读了有关 VeeValidate 动态字段的信息,但它也没有帮助。我有以下错误:

未捕获(承诺中(错误:[vee-validate] 验证不存在的字段:"#29"。首先使用"attach(("。

我的代码 :

<!-- Nom de la catégorie du soin -->
                        <b-row>
                            <b-col sm="3">
                                <label>Catégorie du soin</label>
                            </b-col>
                            <!-- List or typing -->
                            <template v-if="vCatState === 'list'">
                                <b-col sm="7">
                                    <b-form-select key="a" v-model="vCategorie" id="categorySoin"
                                     @change="changeListOfServices(vCategorie)" v-validate="'required'" name="catégorie liste">
                                        <option></option>
                                        <option v-for="categoriesoin in categoriesoins" :key="categoriesoin.id" v-bind:value="categoriesoin.id">
                                            {{categoriesoin.name}}
                                        </option>
                                    </b-form-select>
                                    <span>{{ errors.first('catégorie liste') }}</span>
                                </b-col>
                            </template>
                            <template v-else-if="vCatState === 'typing'">
                                <b-col sm="7">
                                    <b-form-input key="b" type="text" v-model="vCat" id="catSoin"
                                    v-validate="'required'" name="catégorie texte"
                                    />
                                    <span>{{ errors.first('catégorie texte') }}</span>
                                </b-col>
                            </template>
                            <b-col sm="2">
                                <b-button @click="catSoin()">
                                    <font-awesome-icon icon="pen-square"/>
                                </b-button>
                            </b-col>
                        </b-row>

我有一个"选择"和"文本"可以切换。当我关闭我的模态时,我运行这个:this.$validator.reset((;

问题是,如果我通过编辑类型为">

a"的动态字段的行然后编辑类型为"b"的行来打开模态,则会出现上面提到的错误

感谢您的阅读

每当通过 vue 组件显示模态时,我都会遇到这个问题。

我通过唯一地直接分配一个 randing 键来解决这个问题

<modal
    :edited-index="editedIndex"
    :dialog="dialog"
    :key="uniqueKey"
    @dialogAction="executeAction"
/>
It's important to reset the modal state to randomly assign a value to the key on modal open event.

最新更新