Vue中this.$router.push路由传参以及获取方法

项目中通过this.$router.push路由跳转页面传递参数的方式很常见,一般有两种方式:

1.params传参:

this.$router.push({name:'parasetEdit',params:{pk_refinfo:'test',value:'test1'}});

目标页面接收参数:

this.$route.params.pk_refinfo

2.query传参:

this.$router.push({path:'/uapbd/paraset/edit',query:{pk_refinfo:'test',value:'test1'}});

目标页面接收参数:

this.$route.query.pk_refinfo

 

两种方式的区别是query传参的参数会带在url后边展示在地址栏,params传参的参数不会展示到地址栏。需要注意的是接收参数的时候是route而不是router。两种方式一一对应,名字不能混用。

posted @ 2020-03-27 17:15  吴政恒  阅读(6144)  评论(0编辑  收藏  举报