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

146
Vistas
Transferring data from one child component to the parent component to a different child component in Vue without vuex

so i'm new to Vue and i'm trying to pass text from a child component(InputComp) to it's parent and then again reflect the change in a different child component (ReflectiveComp).

        Home
      /      \
     /        \
    /          \
inputComp    ReflectiveComp

So in the template of inputComp i'm using the following input to get the data:

and in the script section of inputComp, i've added a watcher to listen to changes:

export default defineComponent({
  name: 'inputComp, ',
  data(){
      return{
          inputText: ''
      }
  },
  watch:{
      inputText: function(val, oldVal){
          this.$emit('change-input',val);
      }
  }
});

In the parent component (Home), highlight is the variable i want to pass into ReflectiveComp component:

<template>
      <inputComp @change-input="onChange"/>
      <ReflectiveComp :highlight="highlight"/>
</template>
<script>
export default defineComponent({
  components: { Countries, HighlightFilter },
  data(){
    return{
      highlight: 0
    }
  },
  methods:{
    onChange(val){
        this.highlight = val;
    }
  }
});
</script>

and in the ReflectiveComp:

<template>
        <label>{{highlight}}</label>
   </template>
        
   <script>
    
    import { defineComponent } from 'vue'
    
    export default defineComponent({
        name: 'ReflectiveComp',
        props:{
          highlight: Number
        },
    </script>

From the results i've been getting it seems that: the onChange method inside the parent component (Home) is being triggered and updated everytime we change the input in inputComp component.

The issue: the highlight vraiable is not changing in ReflictiveComp.

What am i doing wrong??

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