vm.$broadcast( event, […args] )
-
Arguments:
{String} event
[...args]
-
Usage:
Broadcast an event that propagates downward to all descendants of the current instance. Since the descendants expand into multiple sub-trees, the event propagation will follow many different “paths”. The propagation for each path will stop when a listener callback is fired along that path, unless the callback returns
true
. -
Example:
var parent = new Vue() // child1 and child2 are siblings var child1 = new Vue({ parent: parent }) var child2 = new Vue({ parent: parent }) // child3 is nested under child2 var child3 = new Vue({ parent: child2 }) child1.$on('test', function () { console.log('child1 notified') }) child2.$on('test', function () { console.log('child2 notified') }) child3.$on('test', function () { console.log('child3 notified') }) parent.$broadcast('test') // -> "child1 notified" // -> "child2 notified" // child3 is NOT notified, because child2 didn't return // true in its callback
Please login to continue.