Vue Router hooks
Closed this issue · 6 comments
Hi there,
How i can use beforeRouteUpdate and beforeRouteLeave hooks using vue-facing-decorator?
try @Hook
i've tried something like that:
import { ComponentBase, Ref, Watch, Hook, Vue } from 'vue-facing-decorator'
@ComponentBase({})
export default class OneEventPageComponent extends Vue {
@Hook
beforeRouteLeave(to: any, from: any, next: any) {
console.log(to)
}
}
and beforeRouteLeave isn't been handled when i tried to leave from route.
Log the result of toNative(OneEventPageComponent)
please.
I have experienced this issue.
It may be because the component is not the main component specified in the router definition.
If you move your @Hook
declaration it should work.
@NikitaPoplavskiy Just wanted to mention another possible solution here. Have you been able to resolve this for your context?
@Component({
options: {
beforeRouteUpdate (this: ExampleComponent, to, from, next) {
// do stuff
}
}
})
export default class ExampleComponent extends Vue {}