Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add nested routes example
  • Loading branch information
PanJiaChen committed Jun 21, 2018
commit b266c74298181a79e35ea60b3b958acedb0fb919
1 change: 1 addition & 0 deletions src/icons/svg/nested.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export default {
lineChart: 'Line Chart',
mixChart: 'Mix Chart',
example: 'Example',
nested: 'Nested Routes',
bar: 'Bar',
barProfile: 'Profile',
barPosts: 'Posts',
Table: 'Table',
dynamicTable: 'Dynamic Table',
dragTable: 'Drag Table',
Expand Down
4 changes: 4 additions & 0 deletions src/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export default {
lineChart: '折线图',
mixChart: '混合图表',
example: '综合实例',
nested: '路由嵌套',
bar: 'Bar',
barProfile: 'Profile',
barPosts: 'Posts',
Table: 'Table',
dynamicTable: '动态Table',
dragTable: '拖拽Table',
Expand Down
33 changes: 33 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,39 @@ export const asyncRouterMap = [
]
},

{
path: '/nested',
component: Layout,
redirect: '/nested/bar/profile',
name: 'nested',
meta: {
title: 'nested',
icon: 'nested'
},
children: [
{
path: '/nested/bar', // Must write the full path
component: () => import('@/views/nested/bar/index'), // Parent router-view
name: 'bar',
meta: { title: 'bar' },
children: [
{
path: 'profile',
component: () => import('@/views/nested/bar/profile'),
name: 'bar-profile',
meta: { title: 'barProfile' }
},
{
path: 'posts',
component: () => import('@/views/nested/bar/posts'),
name: 'bar-posts',
meta: { title: 'barPosts' }
}
]
}
]
},

{
path: '/error',
component: Layout,
Expand Down
7 changes: 7 additions & 0 deletions src/views/nested/bar/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<div class="app-container">
<code>Parent View: Bar</code>
<img src="https://wpimg.wallstcn.com/be29a7d2-5ccf-4a2b-888d-8a6c2bbb7aac.png">
<router-view></router-view>
</div>
</template>
6 changes: 6 additions & 0 deletions src/views/nested/bar/posts.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template>
<div style="margin-top:30px;">
<el-alert title="Children: Posts" type="warning" :closable="false">
</el-alert>
</div>
</template>
6 changes: 6 additions & 0 deletions src/views/nested/bar/profile.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template>
<div style="margin-top:30px;">
<el-alert title="Children: Profile" type="success" :closable="false">
</el-alert>
</div>
</template>