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

94
Views
How can I get json collected data from child to parent component in Vue.js?

I have results data in child component but I should bring it to main component.

Main Component in Parent, so each time I click the button, the result should be gathered in main app

 <button @click="showFinalResult">Click me</button>

Child component data here and I just need to show results in json format in parent, the results are input results

 results: [],
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can emit event for child for sending data:

Vue.component('Child', {
  template: `
    <div class="">
      
    </div>
  `,
  data() {
    return {
      results: [1,2,3]
    }
  },
  mounted() {
    this.$emit('update', this.results);
  }
})

new Vue({
  el: '#demo',
  data() {
    return {
      res: [],
      show: false
    }
  },
  methods: {
    getResult(res) {
      this.res = res
    },
    showResults() {
      this.show = !this.show
    }
  }
})

Vue.config.productionTip = false
Vue.config.devtools = false
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <button @click="showResults">Click me</button>
  <p v-if="show">{{ res }}</p>
  <child @update="getResult" />
</div>

about 4 years ago · Juan Pablo Isaza Report
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!