You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/essentials/named-views.md
+57
Original file line number
Diff line number
Diff line change
@@ -27,3 +27,60 @@ const router = new VueRouter({
27
27
```
28
28
29
29
A working demo of this example can be found [here](https://jsfiddle.net/posva/6du90epg/).
30
+
31
+
## Nested Named Views
32
+
33
+
It is possible to create complex layouts using named views with nested views. When doing so, you will also need to name nested `router-view` components used. Let's take a Settings panel example:
-`UserEmailsSubscriptions`, `UserProfile`, `UserProfilePreview` are nested view components
50
+
51
+
**Note**: _Let's forget about how the HTML/CSS should look like to represent such layout and focus on the components used_
52
+
53
+
The `<template>` section for `UserSettings` component in the above layout would look something like this:
54
+
55
+
```html
56
+
<!-- UserSettings.vue -->
57
+
<div>
58
+
<h1>User Settings</h1>
59
+
<NavBar/>
60
+
<router-view/>
61
+
<router-viewname="helper"/>
62
+
</div>
63
+
```
64
+
65
+
_The nested view components are omitted here but you can find the complete source code for the example above [here](https://jsfiddle.net/posva/22wgksa3/)_
66
+
67
+
Then you can achieve the layout above with this route configuration:
68
+
69
+
```js
70
+
{ path:'/settings',
71
+
// You could also have named views at the top
72
+
component: UserSettings,
73
+
children: [{
74
+
path:'emails',
75
+
component: UserEmailsSubscriptions
76
+
}, {
77
+
path:'profile',
78
+
components: {
79
+
default: UserProfile,
80
+
helper: UserProfilePreview
81
+
}
82
+
}]
83
+
}
84
+
```
85
+
86
+
A working demo of this example can be found [here](https://jsfiddle.net/posva/22wgksa3/).
0 commit comments