Vue父组件调用子组件事件方法
Vue父组件向子组件传递事件/调用事件
不是传递数据(props)哦,适用于Vue2.0
方法一:子组件监听父组件发送的方法
方法二:父组件调用子组件方法
子组件:
exportdefault{ mounted:function(){ this.$nextTick(function(){ this.$on('childMethod',function(){ console.log('监听成功') }) }) }, methods{ callMethod(){ console.log('调用成功') } } }
父组件:
exportdefault{ methods:{ click(){ this.$refs.child.$emit('childMethod')//方法1 this.$refs.child.callMethod()//方法2 }, components:{ child:child } }
以上这篇Vue父组件调用子组件事件方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。