Home >Web Front-end >JS Tutorial >How to pass value from child component to parent component in vue
Below I will share with you a method of passing values from a vue sub-component to a parent component. It has a good reference value and I hope it will be helpful to everyone.
The child component registers to trigger the event, and the method after the parent component registers to trigger the child component event is written in the method
The parent component writes like this
<component-a v-on:child-say="listenToMyBoy"></component-a> <p>Do you like me? {{childWords}}</p> methods: { listenToMyBoy: function (somedata){ this.childWords = somedata } }
The sub-component component-a is written like this
<button v-on:click="onClickMe">like!</button> methods: { onClickMe: function(){ this.$emit('child-say',this.somedata); } }
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
By using ueditor in the vue project (detailed tutorial)
By introducing noVNC remote desktop in the vue project What are the method steps
How to use nodejs crawler to use superagent and cheerio
The above is the detailed content of How to pass value from child component to parent component in vue. For more information, please follow other related articles on the PHP Chinese website!