Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
How to integrate a child component into a loop and retrieve the values of the v-model in vue3

For create a generic form with parents/child component , i create this ts file.

 model: "IUser",
 resource: 'users',
 fields: {
   firstname: {
     type: 'text',
     name: 'firstname',
     add: true,
     list: true,
     edit: true,
     label: 'Prenom',
     value: ''
   },
   lastname: {
     type: 'text',
     name: 'lastname',
     add: true,
     list: true,
     edit: true,
     label: 'Nom',
     value: ''
   },  
 }
}

And i called child components into his parent

Parent component


  <el-form
    :model="formData"
    :rules="rules"
  >
  <div v-for="(item, name, index) in models.fields" :key="index">
    name:{{ item.name }} {{ index }}
    <Text 
      v-if="item.type === 'text'"
      :label="item.label"
      v-model="values[index]"
      :ruleName= "item.name"
    />
  </div>
  
  <button @click="SendData()"></button>
  </el-form>

child component

   <div class="col-md-6 fv-row">
    <label class="required fs-6 fw-bold mb-2"
      >{{label}}</label
    >
    <el-form-item :prop="ruleName">  
      <el-input
      v-model="input"
      @input="$emit(`update:${ruleName}`, input)"
    />
    </el-form-item>
  </div>

but I can't have the values of the v-model from the child to the parent. Do you have solution ?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda