Answer the question
In order to leave comments, you need to log in
How to replace route components depending on a condition?
There are a number of routes: /foo
/bar
/baz ...
, each route has its own component:
{
path: '/foo',
componnet: Foo.vue
},
{
path: '/bar',
componnet: Baz.vue
}
{
path: '*'.
component: 404.vue
}
/foo
, I need the native Foo.vue component to be rendered if the condition is true, and if the condition is false, then the Component.vue component (while the url itself should remain /foo in both cases). next({ path: /component })
. Those. everything works, and I render the Component.vue component, but the url changes, and I would like the url to be the one that was originally requested. Is it possible to implement such magic in vue-router?
Answer the question
In order to leave comments, you need to log in
<router-view v-if="условие" />
<Component v-else />
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question