[Vuejs]-How to pass data from method inside component1 to component2

0👍

Passing data to child components is well documented here: https://v2.vuejs.org/v2/guide/components.html

In summary:

<parent>
  <componentx :index="index">
    <component2 :index="index" />
  </componentx>
</parent>

In the parent component all you need in the component is:

data: {
  index: 0
},
methods: {
   onAfterSlideChange(index) {
       this.index = index;
   }
}

And in componentx and component2:

props: ['index'],

Leave a comment