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

首頁 > 語言 > JavaScript > 正文

vue2.0父子組件間傳遞數據的方法

2024-05-06 15:31:33
字體:
來源:轉載
供稿:網友

關于父子組件之間傳遞數據其實文檔上都說得很明白。

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

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(){    //自定義事件,并且給監聽此事件的回調函數的值設為200    this.$emit('ok','200');  }}</script><!-- Add "scoped" attribute to limit CSS to this component only --><style scoped></style>

總結

以上所述是小編給大家介紹的vue2.0父子組件間傳遞數據的方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對錯新站長站網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 阿图什市| 浠水县| 浮梁县| 应用必备| 马关县| 江津市| 北流市| 天气| 连云港市| 崇州市| 通榆县| 曲麻莱县| 清镇市| 德江县| 满洲里市| 临猗县| 即墨市| 乐山市| 威海市| 泾川县| 南溪县| 永泰县| 内江市| 福海县| 和硕县| 阳山县| 胶州市| 来凤县| 安阳市| 峨山| 旌德县| 商丘市| 阳山县| 多伦县| 开化县| 京山县| 常德市| 林芝县| 钟祥市| 莱州市| 乌兰县|