老是记混这两种传参方式,所以特意记录下来。
1.params传参 ,需要传跳转路径的name,传的参数不会在路由地址中显示
例如 :
this.$router.push({ name: 'AdAdd', params: { id: id }})
获取参数值的方法是
this.$route.params.id
2.query传参,需要传跳转路劲的path,传的参数会在路由地址中显示
例如:
this.$router.push({ path: '/add', query: { id: row.id }})
获取参数值的方式是:
this.$route.query.id
另外需注意的是,传参时使用的是$router ,获取时使用的是$route