2

In one of my components the hook beforeRouteEnter is not being called.

The route to this component looks like...

{
    path: '/blunders/:gameID',
    name: 'Blunders',
    component: () => import('../views/Blunders.vue'),
},

My beforeRouteEnter looks like ...

  created () {
    //....
  },
  beforeRouteEnter (to, from, next) {
    console.log("Before Route Enter") //doesn't log
    next(vm => {
      console.log("VMVMVMVMVMVVM") // doesn't log
    });
  },

If I add the exact same beforeRouteEnter() to a different component with route...

  {
    path: '/user',
    name: 'User',
    component: () => import('../views/User.vue')
  },

... it works fine. Why would it work here but not in the other component?

honkskillet
  • 3,007
  • 6
  • 31
  • 47
  • Try with the `beforeRouteUpdate` hook - perhaps it will trigger with your component? – IVO GELOV Jan 05 '21 at 07:27
  • did you got any error in console? – Vishnu Bhadoriya Jan 05 '21 at 07:49
  • No errors in the console. And beforeRouteUpdate is also not firing. – honkskillet Jan 05 '21 at 16:39
  • I notice that `/blunders/:gameID` is a dynamic route. How do you visit this page? Does it fire when you refresh in a `/blunders/:gameID` page? I'm thinking that adding a [`key` property](https://vuejs.org/v2/api/#key) in your route may solve this issue – Mark Jan 12 '21 at 06:44

0 Answers0