Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vuejs2 子组件上的值更改时未更新vee validate错误_Vuejs2_Vee Validate_Kendo Ui Vue - Fatal编程技术网

Vuejs2 子组件上的值更改时未更新vee validate错误

Vuejs2 子组件上的值更改时未更新vee validate错误,vuejs2,vee-validate,kendo-ui-vue,Vuejs2,Vee Validate,Kendo Ui Vue,从Kendo DropDownList中选择值时,该值会更新到模型,但错误始终保留在vee validate的errors对象上 只有在再次提交表单时,才会删除该错误 我试图在小提琴中实现类似的情况,但小提琴显示了实际的行为。一切都很顺利 但当我在实际项目中使用相同的情况时,错误不会重置。我需要再次提交表单以重置错误 值已更新到模型,但错误仍然存在 实际项目中使用的代码: 父组件 <template> <div class="container-fluid">

从Kendo DropDownList中选择值时,该值会更新到模型,但错误始终保留在vee validate的
errors
对象上

只有在再次提交表单时,才会删除该错误

我试图在小提琴中实现类似的情况,但小提琴显示了实际的行为。一切都很顺利

但当我在实际项目中使用相同的情况时,错误不会重置。我需要再次提交表单以重置错误

值已更新到模型,但错误仍然存在

实际项目中使用的代码:

父组件

<template>
<div class="container-fluid">
    <form @submit.prevent="onSubmit('form-client')" data-vv-scope="form-client" autocomplete="off">

        <row-component :model="form_fields" :data-source="dataSourceArray" :scopes="'form-client'">
        </row-component>
        Selected Value: {{form_fields}}
        <br/>
        <button type="submit" class="ui submit button">Submit</button>
    </form>


</div>

</template>

<script>
import rowcomponent from "./Child";
export default {
  components: { "row-component": rowcomponent },
  methods: {
    onSubmit(scope) {
      this.$validator.validateAll(scope).then(result => {
        if (result) {
          // eslint-disable-next-line
          alert("Form Submitted!");
          return;
        }

        alert("Correct them errors!");
      });
    }
  },
  data: function() {
    return {
      form_fields: {
        type: null
      },
      dataSourceArray: [
        { text: "Small", value: "1" },
        { text: "Medium", value: "2" },
        { text: "Large", value: "3" },
        { text: "X-Large", value: "4" },
        { text: "2X-Large", value: "5" }
      ]
    };
  }
};
</script>
<template>
<div>
    <label class="control-label">Drop Down</label>
    <kendo-dropdownlist v-model='model.type' data-vv-name="Type" data-vv-as="Type" :data-source="dataSource" v-validate="'required'"
        :data-text-field="'text'" :data-value-field="'value'" :option-label='"Type"' :filter="'contains'" :index="0" :auto-bind="true"
        class="form-control" :class="{'input': true, 'is-danger': `errors.has(${scopes}.Type)` }">
    </kendo-dropdownlist>
    <span class="is-danger" v-if="`errors.has(${scopes}.Type)`">{{errors.first(`${scopes}.Type`)}}</span>
</div>
</template>

<script>
export default {
  inject: ["$validator"],
  props: {
    model: {
      type: Object,
      default: {}
    },
    dataSource: {
      type: Array,
      default: []
    },
    scopes: {
      type: String,
      default: ""
    }
  }
};
</script>

所选值:{form_fields}}

提交 从“/Child”导入行组件; 导出默认值{ 组件:{“行组件”:行组件}, 方法:{ 提交(范围){ 这是.validator.validateAll(范围)。然后(结果=>{ 如果(结果){ //eslint禁用下一行 警告(“表格已提交!”); 返回; } 警告(“纠正错误!”); }); } }, 数据:函数(){ 返回{ 表格字段:{ 类型:null }, 数据源阵列:[ {文本:“小”,值:“1”}, {文本:“中等”,值:“2”}, {文本:“大”,值:“3”}, {文本:“X-Large”,值:“4”}, {文本:“2X大”,值:“5”} ] }; } };
子组件

<template>
<div class="container-fluid">
    <form @submit.prevent="onSubmit('form-client')" data-vv-scope="form-client" autocomplete="off">

        <row-component :model="form_fields" :data-source="dataSourceArray" :scopes="'form-client'">
        </row-component>
        Selected Value: {{form_fields}}
        <br/>
        <button type="submit" class="ui submit button">Submit</button>
    </form>


</div>

</template>

<script>
import rowcomponent from "./Child";
export default {
  components: { "row-component": rowcomponent },
  methods: {
    onSubmit(scope) {
      this.$validator.validateAll(scope).then(result => {
        if (result) {
          // eslint-disable-next-line
          alert("Form Submitted!");
          return;
        }

        alert("Correct them errors!");
      });
    }
  },
  data: function() {
    return {
      form_fields: {
        type: null
      },
      dataSourceArray: [
        { text: "Small", value: "1" },
        { text: "Medium", value: "2" },
        { text: "Large", value: "3" },
        { text: "X-Large", value: "4" },
        { text: "2X-Large", value: "5" }
      ]
    };
  }
};
</script>
<template>
<div>
    <label class="control-label">Drop Down</label>
    <kendo-dropdownlist v-model='model.type' data-vv-name="Type" data-vv-as="Type" :data-source="dataSource" v-validate="'required'"
        :data-text-field="'text'" :data-value-field="'value'" :option-label='"Type"' :filter="'contains'" :index="0" :auto-bind="true"
        class="form-control" :class="{'input': true, 'is-danger': `errors.has(${scopes}.Type)` }">
    </kendo-dropdownlist>
    <span class="is-danger" v-if="`errors.has(${scopes}.Type)`">{{errors.first(`${scopes}.Type`)}}</span>
</div>
</template>

<script>
export default {
  inject: ["$validator"],
  props: {
    model: {
      type: Object,
      default: {}
    },
    dataSource: {
      type: Array,
      default: []
    },
    scopes: {
      type: String,
      default: ""
    }
  }
};
</script>

下降
{{errors.first(`${scopes}.Type`)}
导出默认值{
注入:[“$validator”],
道具:{
型号:{
类型:对象,
默认值:{}
},
数据源:{
类型:数组,
默认值:[]
},
范围:{
类型:字符串,
默认值:“
}
}
};
这个实现会出什么问题?在此情况下,任何帮助都将不胜感激


有什么指南或参考资料吗

这种情况是由于较旧版本的
vee validate
造成的,我用新版本更新了我的代码,它正在按预期工作

vee验证:2.1.0-beta.7