文章目錄
- 1、 配置路由規則
- 2、跳轉(要寫完整路徑)
- 3、在項目中的實際應用
- 4、測試效果
多級路由的使用、我願稱之為“套娃”。
1、 配置路由規則
使用children配置項:
[
{
path:'/about',
component:About,
},
{
path:'/home',
component:Home,
children:[ //通過children配置子級路由
{
path:'news', //此處一定不要寫:/news
component:News
},
{
path:'message',//此處一定不要寫:/message
component:Message
}
]
}
]
2、跳轉(要寫完整路徑)
<router-link to="/home/news">News</router-link>