国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

vue2.0父子組件間傳遞數(shù)據(jù)的方法

2019-11-19 13:14:43
字體:
供稿:網(wǎng)友

關(guān)于父子組件之間傳遞數(shù)據(jù)其實(shí)文檔上都說得很明白。

 但是如果完全不懂的人做計(jì)也看不懂,下面是一個(gè)小例子,有兩個(gè)文件

1.parent.vue

<template> <child :child-msg="msg" @ok="event"></child></template><script>import child from './child.vue';export default { data(){  return{   msg:'hello worldgogo'  } }, components:{  child }, methods:{  event(val){    console.log(val);  } }}</script><!-- Add "scoped" attribute to limit CSS to this component only --><style scoped></style>

2.child.vue

<template>  <p>{{childMsghello}}</p></template><script>export default {  props: ['childMsg'],  data(){    return{      childMsghello:this.childMsg+'this is child'    }  },  created(){    //自定義事件,并且給監(jiān)聽此事件的回調(diào)函數(shù)的值設(shè)為200    this.$emit('ok','200');  }}</script><!-- Add "scoped" attribute to limit CSS to this component only --><style scoped></style>

總結(jié)

以上所述是小編給大家介紹的vue2.0父子組件間傳遞數(shù)據(jù)的方法,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)武林網(wǎng)網(wǎng)站的支持!

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 江山市| 柘荣县| 凤山市| 中山市| 凤阳县| 永嘉县| 麻江县| 新昌县| 漳浦县| 贺州市| 岫岩| 九龙城区| 通山县| 雅江县| 修武县| 东港市| 堆龙德庆县| 香河县| 岑巩县| 五大连池市| 平湖市| 东源县| 青龙| 屏东市| 荣成市| 喀什市| 门源| 永福县| 色达县| 桂阳县| 宁强县| 汉阴县| 水城县| 南部县| 岑溪市| 太原市| 十堰市| 富川| 平武县| 桦川县| 芮城县|