Skip to content

Commit 4d3cbf5

Browse files
skirtles-codeposva
andauthored
docs: omitting parent components for nested routes (#2127)
* docs: omitting parent components for nested routes * Update packages/docs/guide/essentials/nested-routes.md --------- Co-authored-by: Eduardo San Martin Morote <[email protected]>
1 parent f06f8a8 commit 4d3cbf5

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

packages/docs/.vitepress/theme/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const i18nLabels = {
1515
}
1616

1717
const theme: Theme = {
18-
...DefaultTheme,
18+
extends: DefaultTheme,
1919
Layout() {
2020
return h(DefaultTheme.Layout, null, {
2121
// 'home-features-after': () => h(HomeSponsors),

packages/docs/guide/essentials/nested-routes.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,24 @@ const routes = [
128128
},
129129
]
130130
```
131+
132+
## Omitting parent components <Badge text="4.1+" />
133+
134+
We can also take advantage of the parent-child relationship between routes without needing to nest route components. This can be useful for grouping together routes with a common path prefix, or when working with [route meta fields](../advanced/meta).
135+
136+
To achieve this, we omit the `component` and `components` options from the parent route:
137+
138+
```js
139+
const routes = [
140+
{
141+
path: '/admin',
142+
children: [
143+
{ path: '', component: AdminOverview },
144+
{ path: 'users', component: AdminUserList },
145+
{ path: 'users/:id', component: AdminUserDetails },
146+
],
147+
},
148+
]
149+
```
150+
151+
As the parent doesn't specify a route component, the top-level `<router-view>` will skip over the parent and just use the component from the relevant child instead.

0 commit comments

Comments
 (0)