Callback function in beforeRouteEnter is not triggered

Tags: , ,

I have simple routes: /follower/:token/edit and /follower/new

When I move from the first one to the second one by $router.push(‘/follower/new’) befoureRouteEnter hook is triggered but callback function inside ‘next’ function does not (problem does not exist when I go from different routes or reload page).

beforeRouteEnter(to, from, next) {
    debugger; //is triggered
    next(vm => {
        debugger; //is not triggered

Do you know what can be wrong?

Vue: 2.5.17 Vue-router: 3.0.1



If you are navigating between routes using the same component – vue tries to optimize by delivering a cashed version. I’m not sure if this is what you are experiencing – but you could try to force re-instantiation by adding a key value to your <router-view>.

A ‘common’ way to do this is to use $route.path

<router-view :key="$route.path"></router-view>

Source: stackoverflow