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)
@dudesweet100 In 2.0 it’s renamed to
$router.push, and$router.gois an alias ofwindow.location.gowindow.history.goBTW, on latest version,
this.$route._routerwas changed tovm.$route.router, just so you are aware.there is no
vm.router. There isvm.$route. So you can dothis.$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.