vue-router: router.go() does not work

I have a basic rule to redirect my home page to resumes page. my rule :

...
  ready: function() {
    if(this.isLoggedIn){
      this.router.go("/resumes");
    }
  },
...

my route map :

module.exports = {
  '/': {
    component: require('./views/home')
  },
  '/auth/login': {
    component: require('./views/auth/login')
  },
  '/auth/register': {
    component: require('./views/auth/register')
  },
  '/resumes': {
    component: require('./views/resumes')
  },
  // 404 NotFound
  '*': {
    component: {
      template: "not found"
    }
  }
};

But when I login, router changes url on browser but still show home page. It does not redirect me to /resumes page? what is wrong?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 17 (4 by maintainers)

Most upvoted comments

@dudesweet100 In 2.0 it’s renamed to $router.push, and $router.go is an alias of window.location.go window.history.go

BTW, on latest version, this.$route._router was changed to vm.$route.router, just so you are aware.

there is no vm.router. There is vm.$route. So you can do this.$route._router.go('/resumes').

omg it took me 2 hours to figure out that router.go was the equivalent of window.history.go, thank’s to @fnlctrl … Weird we couldn’t find it faster :p but thank’s anyway !

@kamuran21 😅 Oops, was a typo, should be window.history.go.