[Vuejs]-VueJS: Call method from component using eventbus

0👍

Using Vue’s ref directive should work for you:

<search-comp ref="search"></search-comp>

And then in your eventbus use:

var search = parent.$refs.search;
search.doSearch(val);

Here is a working demo:
https://codepen.io/egerrard/pen/vpJdQJ

And here is the documentation:
https://v2.vuejs.org/v2/api/#ref

Leave a comment