vue使用$emit时,父组件无法监听到子组件的事件
来源:互联网 发布:太原知豆d1补贴后价格 编辑:程序博客网 时间:2024/06/16 06:40
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>
阅读全文
1 0
- vue使用$emit时,父组件无法监听到子组件的事件
- Vue $emit $refs子父组件间方法的调用
- 子组件使用$emit事件触发父组件实现购物车功能
- Vue父组件调用子组件事件
- Vue.js组件component关于分页功能、自定义事件的$.Emit()的使用
- Vue之模态框确认组件---使用$emit触发父组件的methods
- vue组件之emit
- vue---父调子 $refs (把父组件的数据传给子组件)子调父 $emit (把子组件的数据传给父组件)
- vue子组件的使用和事件传递
- vue组件中$emit()的作用
- vue父组件点击触发子组件事件
- vue自定义事件 子组件向父组件通信
- vuejs2.0实现分页组件,使用$emit进行事件监听数据传递
- vuejs2.0实现分页组件,使用$emit进行事件监听数据传递
- vuejs2.0实现分页组件,使用$emit进行事件监听数据传递
- vue笔记---子组件把数据发送到父组件
- 子组件传递数据到父组件(vue.js)
- vue---vue中如何自定义事件?子组件事件如何向上触发父组件事件?
- 23&24day-网络
- 针对矩阵的一类动态规划处理
- Weblogic 异常 java.net.NoRouteToHostException: No route to host
- 华为机试:最高分是多少
- Hadoop之Flume架构以及应用介绍
- vue使用$emit时,父组件无法监听到子组件的事件
- redis 3.2 集群环境搭建
- Android webview长按图片保存到本地
- 51nod 1349 最大值
- 流式处理新玩法,Esper和Storm的联合统计分析
- 获取视频的宽高和长度
- Java输入输出(I/O)流
- 时间范围比较
- JZOJ 1319. 邮递员