Reputation: 4705
In-Component guard beforeRouteLeave
is triggered when clicking on a <router-link to="/">
. However, it's not triggered when I call router.push({ path: "/" })
programmatically.
Is there something wrong with that?
Edit
I just tried to make a sandbox and found out it occurs just if navigating to the same path with dynamic parameter.
For example navigating from /item/1
to /item/2
causes this problem.
Upvotes: 3
Views: 2044
Reputation: 736
I think this is an unexpected behavior, it'd help more if you provide more context.
EDIT
You don't actually leave the route if you just pass a different parameter, which is why beforeRouteLeave
doesn't get triggered.
Instead, you might want to use beforeRouteUpdate
For more information about In-Component Guards see the docs.
Upvotes: 6