国产探花免费观看_亚洲丰满少妇自慰呻吟_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時,父組件無法監聽到子組件的事件實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 上杭县| 怀安县| 太和县| 图木舒克市| 许昌县| 江山市| 岳阳县| 济南市| 普兰县| 西充县| 佛学| 平陆县| 岗巴县| 康乐县| 金塔县| 搜索| 高陵县| 商水县| 扎鲁特旗| 垣曲县| 治县。| 泰州市| 鄄城县| 克山县| 浦县| 东丰县| 增城市| 石阡县| 房产| 古交市| 西乌珠穆沁旗| 安远县| 枝江市| 嵩明县| 德庆县| 康马县| 康马县| 威信县| 莎车县| 承德县| 拉萨市|