1.向上通知
Vue.prototype.$dispatch = (eventName, value) => {
let parent = this.$parent
while(parent){
parent.$emit(eventName, value)
parent = parent.$parent
}
}
2.向下广播
Vue.prototype.$boardcast = (eventName, value) => {
const boardcast = (children) => {
children.foreach(child =>{
child.$emit(eventName, value)
if(child.$children) {
boardcast (child.$children)
}
})
}
boardcast(this.$children)
}