Vue路由传参
对路由传参的总结,不对之处望包涵,指正。记录Vue
路由传参的两种方式query
和params
路由传参之-- this.$route.query
<router-link to='/home?id=123&name=zhangsan'>路由传参query</router-link>
this.$route.query.id
, 可拿到123,此api无需配置路由规则
this.$route.query.name
, 可拿到,zhangsan此api无需配置路由规则
路由传参之-- this.$route.params
<router-link to="/home/123/zhangsan">
路由传参params
</router-link>
this.$route.params.id
,不可以拿到123,都需要配置路由规则为: {path:'/home/:id/:name',Component:home}
this.$route.params.name
, 拿不到zhangsan
,都需要配置路由规则为: {path:'/home/:id/:name',Component:home}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。