Ideally, setting a component state from the router would be considered an anti-pattern. What you are looking for is meta fields.
You should let the component load but in created() hook or by observing the $route object injected in each component, read the meta config and then update the component's state like:
const HomeComponent = Vue.component('home-comp', {
// Other options...
watch: {
$route() {
if (this.$route.meta.isLogin === true) {
// Load Login Dialog Box
} else if (this.$route.meta.isRegistration === true) {
// Load User Registration Dialog Box
}
}
}
});
Your router config would look like:
const router = new VueRouter({
routes: [
{
path: '/login',
component: HomeComponent,
// a meta field
meta: { isLogin: true },
children: []
},
{
path: '/register',
component: HomeComponent,
// a meta field
meta: { isRegistration: true }
},
{
path: '/',
component: HomeComponent
}
]
});
Alternately, you can go away the need for meta field. You can simply check the $route config for route name or check current URL and then make the decision.
TLDR; Handle this logic inside your HomeComponent. Or use Guard if you can use different component for each route.