-
在vue-router中,有两大对象被挂载到了实例this
-
r o u t e ( 只 读 、 具 备 信 息 的 对 象 ) 、 route(只读、具备信息的对象)、 route(只读、具备信息的对象)、router(具备功能函数)
-
查询字符串
- 1: 去哪里
<router-link :to="{name:'detail',query:{id:1} }">xxx</router-link>
- 2: 导航(查询字符串path不用改)
{name:'detail',path:'/detail',组件}
- 3:去了干嘛。获取路由参数(要注意是query还是params和对应的id名)
this.$route.query.id
- 1: 去哪里
-
path 方式
-
1: 去哪里
<router-link :to="{name:'detail',params:{id:1} }">xxx</router-link>
-
2: 导航(path方式需要在路由规则上加上/:xxx)
{name:'detail',path:'/detail/:id',组件}
-
3:去了干嘛。获取路由参数(要注意是query还是params和对应的id名)
- this.$route.params.id`
-