1.首先定义一个公共的vue组件;
var eventHub = new Vue();
2.在事件当前的组件中,在created中,用$on向公共的组件eventHub传递,translate是自定义的,getCardNum(data)是要在外部调用的方法;
eventHub.$on('translate', function (data) {
that.getCardNum(data);
});
3.最后在父组件中,注意负组件要用一个变量保存,var vm = new Vue({});
4.在父组件中的methods的方法中定义一个方法,在方法里用$emi