首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >验证子组件Vue vee-验证

验证子组件Vue vee-验证
EN

Stack Overflow用户
提问于 2018-10-12 13:03:26
回答 2查看 11.9K关注 0票数 10

应用程序(父级)

嗨,我有这些组件(子) TextComponent InfoErrorForm

当我从父组件中按下submit时,App不会验证此表单。因此,我尝试在子组件(TextComponent)中使用inject $validator进行验证,并提供但不显示消息错误。如果你能帮助我在父组件中验证子表单。这是我的代码

AppComponent

<template>
      <div>
        <!-- Form validar numero max input -->
        <form :class="{'was-validated': error_in_form_save_progress}" >

           <card-shadow v-for="(texto,key) in sections_template.texts" :key="key" > 
            <texto-component 
              :orden="key+2"
              v-model="sections_template.texts[key].content" 
              :tituloComponente="texto.title" 
              :inputName="texto.title" >
              <template slot="section_show_error_validate_input">
                <info-error-form 
                  :listErrors='errors' 
                  :name_field = "texto.title" 
                  v-show = "error_in_form_save_progress" >
                </info-error-form>
              </template>
            </texto-component>
          </card-shadow>

        </form>

        <div class="row foot_button" >
          <div class="offset-md-3 col-md-3">
            <button class="btn" @click.prevent="save_progrees"> Guardar Cambios</button>
          </div>

        </div>
      </div>
    </template>

    <script>

      export default {

        provide() {
       return {
         $validator: this.$validator,
       };
    },
        data: function(){
          return {
            sections_template: {
              texts:[
                {
                  section_template_id: 1,
                  type: "texto",
                  title: "fundamentacion",
                  content: ""
                },
                {
                  section_template_id: 2,
                  type: "texto",
                  title: "sumilla",
                  content: ""
                }
            ] },
            error_in_form_save_progress: true
          }
        },
        methods:{
          save_progrees(){
             this.$validator.validateAll().then((result) => {
            if (result) {
             this.error_in_form_save_progress = false;
             alert("se guardaran cambios");
             return
            }
            this.error_in_form_save_progress = true;
            });

          }
        }
      }
    </script>
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52772567

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档