vue 组件之间的传值
生活随笔
收集整理的這篇文章主要介紹了
vue 组件之间的传值
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
父向子傳值
父組件 <v-footer :projectdat="dat"></v-footer> export default {data() {return {dat: 'hahah', }} }
父組件這么寫 <component-a v-on:child-say="listenToMyBoy"></component-a><p>Do you like me? {{childWords}}</p>methods: {listenToMyBoy: function (somedata){this.childWords = somedata}}
父組件 <v-footer :projectdat="dat"></v-footer> export default {data() {return {dat: 'hahah', }} }
子組件:
export default {data() {return {code: localStorage.getItem('orgcode'),id: this.$route.params.id,}},props: ['projectdat'] } 子向父傳值父組件這么寫 <component-a v-on:child-say="listenToMyBoy"></component-a><p>Do you like me? {{childWords}}</p>methods: {listenToMyBoy: function (somedata){this.childWords = somedata}}
?
子組件component-a這么寫
<button v-on:click="onClickMe">like!</button>methods: {onClickMe: function(){this.$emit('child-say',this.somedata);}?
轉載于:https://www.cnblogs.com/wangzhichao/p/7993163.html
總結
以上是生活随笔為你收集整理的vue 组件之间的传值的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 字典dict类型
- 下一篇: Hive 2.3.2 Installat