Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!