Query参数取值
http://www.csdn/index?id=10&age=123
取值
this.$route.query.id//获取id值
this.$route.query.age//获取age值
传值
<router-link :to="{path:'/index',query:{ id:10,age:123 }}"></router-link>
携带参数跳转到指定路由
this.$router.push('/login')
//直接跳转
this.$router.push({path:'/user',query:{ id:123,age:100} })
//携带参数跳转
路径参数取值
http://www.csdn/index/10/123
提前配置路由占位符
export default new VueRouter({//暴露出去使用routes:[{ name:'user',path: '/user/:id/:age',component: User,}]
})
赋值
必须是name 不可以是path,或者可以使用字符串拼接
<router-link :to="{name:'user',params:{ id:123,age:666 }} ">跳转用户</router-link>
取值
$route.params.id
$route.params.age