I'm using VueJS and want to trigger a method inside a .Vue component. The eventbus is working properly. I have created this according this article: https://alligator.io/vuejs/global-event-bus/
Within the eventbus function I want to call the method from the component. How can I do this? I tried this.doSearch(), but this doesn't work. Any advises?
//Event listener
EventBus.$on('i-got-searched', search => {
if (!(search === undefined || search === null)) {
console.log(`Debug: ${search}`)
}
});
//Component
export default {
methods: {
doSearch(input) {
console.log(input);
}
}
}