Vuejs中父组件主动调用子组件的方法
转自:https://www.jianshu.com/p/d6e2611df0b6
1.首先在子组件中进行事件广播
created: function(){ this.$on('handleChange', function(){ console.log('something handled!'); }); }
2. 在父组件中指定子组件的ref,如child,然后通过以下方式调用:
this.$refs['child'].$emit('handleChange');
浙公网安备 33010602011771号