Reputation: 21
I'm developing my first app using NativeScript Vue and I was hoping someone could help me with an issue here: How do you set an event listener to a component programmatically? In a normal vue app you would do: component.$on('eventName', eventHandler)
, but that is not working. I tried to get the answer searching the matter in google, but with no results. Thank you all
Upvotes: 0
Views: 1017
Reputation: 21
I resolved what I needed by using the nativescript event handler instead of vue's event handler interface. https://docs.nativescript.org/core-concepts/events
I was trying to listen to a page event, so my code looks something like this:
const Page = require('tns-core-modules/ui/page').Page
const componentPage = vueComponent.nativeView.page
componentPage.on(Page.navigatedFromEvent, myHandlerMethod)
Upvotes: 1