@Component({
mixins: [template],
components: {
Sidebar
}
})
export default class AppContentLayout extends Vue {
@Prop({default: 'AppContent'})
title: string;
@Watch('$route')
beforeRouteUpdateHandler (to: Object, from: Object, next: Function) {
// handle route updates...
// remember to call next()
Logger.log(to)
Logger.log(from)
next();
}
}
According to the documentation, the beforeRouteUpdate
method should accept parameters like to
, from
, and next
. However, in my case, I always find that next
is undefined, whether I use the watch option from a property decorator or when I include it in the mixins
within @component
. In both scenarios, the hook gets triggered, but the value of next
remains undefined
. Even though I assumed that next
would be present if required, as mentioned in the docs:
Make sure to always call the next function, otherwise the hook will never be resolved.
This led me to believe that next
should always be available. If it's the case that it is only available when explicitly provided, a simple check like this might help:
if(isFunction(next)) next()
In essence, my question boils down to: is next
accessible only if passed explicitly?