VUE之兄弟组件 $emit和$on、$bus的用法

vue原型链挂载总线:
main.js文件夾中引用 Vue.prototype.bus = new Vue();

子组件触发方法:this.$bus.$emit("updateMessageCount")

子组件接受方法并调用:this.$bus.$on("updateMessageCount", this.getUnreadCount);

this.getUnreadCount是一个方法

原文地址:https://www.cnblogs.com/Jerry1208/p/12929252.html