[Vuejs]-How to make if statement in beforeEach only work on loadup once?

0👍

How about

let redirectToFirstPhase = true;

router.beforeEach((to, from, next) => {

  // let slug = store.state.profile.currentPhase.slug;
  if (to.path === '/phase/default' && redirectToFirstPhase) {
    redirectToFirstPhase = false;
    next('/phase-first');
  } else {
      next();
  }
})

Leave a comment