一个组件传递消息给另一个组件(任意组件传递)
全局配置
/** 添加事件总线$bus,用以组件之间通信 */
Vue.prototype.$bus = new Vue()
组件一:
async onOK()
{
this.$bus.$emit('updateSjzbTree')
}
组件二:
created()
{
this.init()
this.$bus.$on('updateSjzbTree', this.init)
},
使用场景:一个页面数据变动,需要另一个页面也相应变动
2751

被折叠的 条评论
为什么被折叠?



