Home > Web Front-end > JS Tutorial > How to pass value from child component to parent component in vue

How to pass value from child component to parent component in vue

亚连
Release: 2018-06-04 14:11:29
Original
3084 people have browsed it

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
   }
  }
Copy after login

The sub-component component-a is written like this

<button v-on:click="onClickMe">like!</button>
methods: {
  onClickMe: function(){
  this.$emit(&#39;child-say&#39;,this.somedata);
  }
 }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template