layout: 13
title: 13.《this.$router.push()参数详解》
date: 2021-03-07 14:58:00
vue中this.$router.push路由传参以及获取方法
通过this.$router.push路由跳转页面传递参数的方式,一般有两种方式:
1.params传参:
this.$router.
push({
name:'parasetEdit',
params:{
pk_refinfo: 'test',
value: 'test1'
}
});
目标页面接收参数:
this.$route.params.value
2.query传参:
this.$router.
push({
path:'/uapbd/paraset/edit',
query:{
pk_refinfo:'test',
value:'test1'
}
});
目标页面接收参数
this.$route.query.value
两种方式的区别是query传参的参数会带在url后边展示在地址栏,params传参的参数不会展示到地址栏。需要注意的是接收参数的时候是route而不是router。两种方式一一对应,名字不能混用。