Currently, I have a Vue.js components which contains a list of other components. I know that the common way of working with vue is passing data to children, and emitting events to parents from children.
However, in this case I want to execute a method in the children components when a button in the parent is clicked. Which would be the best way to do it?
One suggested way is to use a global event hub. This allows communication between any components that have access to the hub.
Here is an example showing how an event hub can be used to fire a method on a child component.
Here is a simple one which worked for me
You can create below helper method in methods in your parent component:
And call child component method in this way:
I don't test it for Vue>=2.0