1.嵌套路由
const routes = [
{
path: '/user/:id', //路径名
component: User, //组件名
children: [ //嵌套路由
{// 当 /user/:id/profile 匹配成功
path: 'profile',
component: UserProfile,// UserProfile 将被渲染到 User 的 <router-view> 内部
},
{// 当 /user/:id/posts 匹配成功
path: 'posts',
component: UserPosts,// UserPosts 将被渲染到 User 的 <router-view> 内部
},
],
},
]
2.name命名路由
const routes = [
{
path: '/user/:username',
name: 'profile',
component: User
}]<router-link :to="{ name: 'profile', params: { username: 'erina' } }">
User profile
</router-link>
3.重定向
const routes = [{ path: '/home', redirect: '/' }]
4.别名
const routes = [{ path: '/', component: Homepage, alias: '/home' }]
1016

被折叠的 条评论
为什么被折叠?



