Answer the question
In order to leave comments, you need to log in
How to make a proper redirect from parent to child route?
There are routes:
const routes = [
{
path: '/dashboard',
name: 'dashboard',
component: dashboardMainPage,
children: [
{
path: 'auth',
name: 'dashboard.auth',
component: dashboardAuthPage
}
]
}
];
const router = new VueRouter({
mode: 'history',
routes
});
created() {
if(this.$store.getters.isLogged){
//
}
else {
this.$router.go({name: 'dashboard.auth'})
}
}
"vue": "2.4.2",
"vuex": "^2.3.1",
"vue-router": "^2.7.0"
Answer the question
In order to leave comments, you need to log in
It cycles because 'dashboard.auth' is in the 'dashboard' component
and it turns out that when entering 'dashboard' it redirects to 'dashboard.auth' which is in 'dashboard' which redirects to 'dashboard.auth' which is in 'dashboard' ' etc.
You just need to expand these components
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question