一、路由传参:https://www.jianshu.com/p/d276dcde6656
第一种:路由中配置(页面刷新数据不会丢失)
path: '/particulars/:id',
this.$router.push({ path: `/particulars/${id}`, })
获取参数
this.$route.params.id
第二种:通过params来传递参数(不需要路由配置,刷新页面数据会丢失)
注意:这种路由跳转 不是通过 path 跳转的,而是通过name跳转的。【这种参数可以猜到,内部应该是把name对应的字段(所以不适合用path字段)挂载route属性下,这样属性中就可以存放相应的参数。】
this.$router.push({ name: 'particulars', params: { id: id } })
获取参数
this.$route.params.id
第三种:通过query来传递参数(刷新页面数据还在,这种方法在url上会显示?id=**)
this.$router.push({ path: '/particulars', query: { id: id } })
获取参数
this.$route.query.id