1、传递参数
<!-- 路由跳转并携带params参数,to的字符串写法 -->
<router-link :to="`/home/message/detail/${m.id}/${m.title}`"></router-link>
<!-- 路由跳转并携带params参数,to的对象写法 -->
<router-link :to="{
name:detail //此处不能用path
params:{
id:m.id,
title:m.title}
}"></router-link>
注意:params 若用to的对象写法,只能用name,不能用path
2、接收参数
$router.params.id
$router.params.title
3、配置路由
const router = new Router({
routes: [ {
path: '/search/:id/:title',//params配置路由映射必须有占位
component: Search
}]