Here is the existing code snippet:
<div id='vnav-container'>
<input type="text" v-model="searchTerm" v-on:keyup="search" class="vnav-input">
<menu :items="menu"></menu>
</div>
The main
component features a search input
and a menu
component.
When a user performs a search within the main
component, I need to trigger a method in the menu
component, or emit an event, or some other method of communication to instruct the menu
component to filter itself based on the new criteria.
I have come across suggestions that directly calling methods on child components is discouraged, and instead events should be used. I am currently reviewing the documentation, but so far I have only found examples of parent-child communication, not the reverse.
What is the best approach for communicating with the menu component as the search criteria changes?
UPDATE
Some blog posts mention a now-missing $broadcast
method designed for communicating with child components. However, information about this feature has seemingly disappeared from the documentation. The previous URL for reference was: http://vuejs.org/api/#vm-broadcast