轻量级 视图层框架
复杂组件间传值,引进其他的工具或者设计模式
1.vuex
2.总线机制
//main line 1.在main.js中注册全局的bus Vue.prototype.bus=new Vue(); 2.在组建中使用 子组建使用:this.bus.$emit(‘自定义事件名‘,data) methods:{ handleClicks(){ this.bus.$emit(‘openMenu‘,true) } } 父组建使用: this.bus.$on("自定义事件名", msg => {}) mounted() { this.bus.$on("openMenu", msg => { this.show = msg; }); }
原文:https://www.cnblogs.com/-constructor/p/11944538.html