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

首頁 > 編程 > JavaScript > 正文

vue使用$emit時,父組件無法監聽到子組件的事件實例

2019-11-19 14:17:39
字體:
來源:轉載
供稿:網友

vue使用$emit時,父組件無法監聽到子組件的事件的原因是$emit傳入的事件名稱只能使用小寫,不能使用大寫的駝峰規則命名

<div id="counter-event-example">  <p>{{ total }}</p>  <button-counter v-on:ee="incrementTotal"></button-counter>  <button-counter v-on:eEvent="incrementTotal"></button-counter>  <child ref="cmpSelect" v-on:ee="incrementTotal" option-api-url="/api/admin/cms/cmsCategory/getOptions.do"></child> </div> <script>  Vue.component('button-counter', {   template: '<button v-on:click="increment">{{ counter }}</button>',   data: function () {    return {     counter: 0    }   },   methods: {    increment: function () {     this.counter += 1     this.$emit('ee', this.counter);//有效     this.$emit('eEvent', this.counter);//無效,不能使用大寫的駝峰規則命名    }   },  })  new Vue({   el: '#counter-event-example',   data: {    total: '點擊下面的按鈕'   },   methods: {    incrementTotal: function (b) {     this.total = b;    }   }  }) </script>

以上這篇vue使用$emit時,父組件無法監聽到子組件的事件實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 桂林市| 白沙| 张家港市| 滁州市| 嘉鱼县| 鸡泽县| 青铜峡市| 松溪县| 唐河县| 宜昌市| 昆山市| 特克斯县| 商丘市| 留坝县| 邯郸市| 沾化县| 沿河| 金昌市| 桦南县| 黄冈市| 蒲江县| 那曲县| 泊头市| 通辽市| 台州市| 普格县| 曲水县| 上林县| 芮城县| 财经| 得荣县| 汕尾市| 茌平县| 宣武区| 静海县| 建德市| 绥中县| 沾化县| 洞口县| 吉首市| 乐山市|