嵌套路由

使用方法

1.配置路由规则,使用children配置项:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
routes:[
{
path:'/about',
component:About
},
{
path:'/home',
component:Home,
children:[ //通过children配置子级路由
{
path:'news', //此处一定不要写‘/news’
component:News,
},
{
path:'message', //此处一定不要写‘/message’
component:Message,
}
]
}
]

2.在需要的vue中填写标签

1
<router-link to="/home/news">News</router-link>