Empty parent in nested routes
See original GitHub issueIt could be interesting to have a parent route definition without any component and having the matched children rendered in the root <router-view>
. Here is an example:
var routes = [
{
path: '/:lang',
children: [
{
path: '',
component: WelcomeComponent
},
{
path: 'hello/:name',
component: HelloComponent
}
]
}
]
This won’t work. Instead, this is what I am doing:
var routes = [
{
path: '/:lang',
// create a container component
component: {
render (c) { return c('router-view') }
},
children: [
{
path: '',
component: WelcomeComponent
},
{
path: 'hello/:name',
component: HelloComponent
}
]
}
]
But the original problem was to scope my routes by their definitions only, not by components.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:59
- Comments:23 (3 by maintainers)
Top Results From Across the Web
React-Router nested routes loading blank page instead of ...
You need to remove the exact prop from the Dashboard route (present in Switch ) while doing the child routing.
Read more >[Vue] Empty parent in Nested Routes of Vue Router
const router = new VueRouter({ routes: [{ path: '/', component: Home, children: [{ path: 'users', component: UserPage, children: [{
Read more >react router v6 how to leave parent element
The Guide to Nested Routes with React Router ... You declaratively nest the child Route as a children of the parent Route. Like...
Read more >Nested Routes
With Vue Router, you can express this relationship using nested route configurations. Note that nested paths that start with / will be treated...
Read more >Routing
Nested Routes - The general idea of routes mapping to segments of the URL ... Parent Layout Route or Parent Route - A...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My take on this:
Pretty straightforward, although I can understand the desire for a utility function for this.
kinda shitty that you can’t just omit the Component when you want the child to be rendered instead of the parent…