{{m.title}}
// ...
{ // 二级路由
path: 'message',
component: Message,
children: [{
name: 'detail',
path: 'details/:id/:title/:desc', // 配置占位符
component: Details,
}]
}
// ...
- 消息标题:{{$route.params.title}}
- 消息内容:{{$route.params.desc}}

{{m.title}}
router/index.js 和 Details.vue 沿用上面第一种时的更改即可
配置路由,声明接收params参数
{
path:'/home',
component:Home,
children:[
{
path:'news',
component:News
},
{
component:Message,
children:[
{
name:'xiangqing',
path:'detail/:id/:title', //使用占位符声明接收params参数
component:Detail
}
]
}
]
}
传递参数
跳转
跳转
特别注意:路由携带params参数时,若使用to的对象写法,则不能使用path配置项,必须使用name配置!
接收参数:
$route.params.id
$route.params.title