我一直在尝试使它工作片刻,但我还没有找到解决方案。我已经阅读了有关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”类型的行来打开模态,则会出现上述错误。
感谢阅读
答案 0 :(得分:0)
在模式上也有同样的问题,我在github上发现了这个线程:validating a non existing field
实际上坚持验证对我来说是错误。我使用了v-validate.persist="'required'"
,它消除了控制台中的错误,并在元素上保留了is-valid类。当然,直到刷新窗口为止。希望对您有帮助
答案 1 :(得分:0)
每当通过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.