$ Dispatch and $ broadcast source code:
function Broadcast (componentName, eventName, the params) {
the this . $ children.forEach (Child => {
const name = Child. options.name $
// component name componentName consistent with the incoming
IF (name === componentName) {
// eventName event trigger subassembly
child $ emit.apply (child, [eventName] .concat (the params)).
} the else {
broadcast.apply (child, [componentName, eventName] .concat ([the params])); // eslint- Line-disable
}
})
}
Export default {
Methods: {
// trigger up event
dispatch $ (componentName, eventName, params) {
// get the parent instance
the let parent = the this . $ parent || the this . $ root
// get the component name
the let name = parent. $ options.name
// recursive lookups consistent with the componentName component name
the while (parent && (! name || name! == componentName)) {
parent = parent. $ parent
IF (parent) {
name = parent. $ options.name
}
}
IF (parent) {
// component to trigger eventName event
parent. $ emit.apply (parent, [eventName] .concat (the params))
}
},
// send event to the promoter (Sun) assembly
$ Broadcast (componentName, eventName, the params) {
broadcast.call ( the this , componentName, eventName , the params)
}
}
}