tft每日頭條

 > 生活

 > vue子組件取父組件的值

vue子組件取父組件的值

生活 更新时间:2025-05-02 23:18:58

這裡的child-say 是指定的不能更改

父組件

<component-a v-on:child-say="listenToMyBoy"></component-a>

<p>Do you like me? {{childWords}}</p>

methods: {

listenToMyBoy: function (somedata){

this.childWords = somedata

}

}

子組件

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

vue子組件取父組件的值(子組件向父組件傳值)1

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关生活资讯推荐

热门生活资讯推荐

网友关注

Copyright 2023-2025 - www.tftnews.com All Rights Reserved