laravel - 即使使用密钥,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 组件显示模式时,我都会遇到这个问题。
我通过直接分配一个排序键来解决这个问题
<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.
推荐阅读
- excel - 使用变量将范围从一个工作表复制到另一个工作表
- reactjs - API 调用返回数据但不渲染
- php - 制作一个包含 phpmyadmin tablerow 的 HTML Tablerow,以通过带有方法 post 的表单提交将信息发送到 edit.php
- arrays - 如何在 Typescript 中将接口属性定义为字典?
- docker - 运行 docker 容器时带有 2 个路径的命令
- tensorflow - 进行迁移学习时如何在 vgg16 中添加自定义层?
- vue.js - 按钮单击测试失败并使用 Jest / VueJS
- react-native - 单击图像时,显示/隐藏(淡入/淡出)文本+图标叠加
- jooq - 从 JOOQ 解析器获取 SQL 选择列的列表
- javascript - 将年份从输入添加到 ajax 调用