- 跳转时用query传参会拼接参数在路径后面
this.$router.push({path: '/userManagement',query:{id:this.regionId,label:this.label}});
接受值:this.$route.query.id
- 用params不会拼接
this.$router.push({path: '/userManagement',params:{id:this.regionId,label:this.label}});
- 接受值:this.$route.params.id
this.$router.go(-1); 直接跳转上一步
更新笔记:
路由配置
{ path: '/editCardetail', name: 'editCardetail', component: EditCardetail },
使用$router.push 拼接参数传参
this.$router.push('/editCardetail?id=this.id')
path不能与params一起使用,需要通过path来匹配路由的时候,使用query来传参。
query要用path来引入,params要用name来引入,接收参数都是类似的,分别是this.route.query.name和this. route.query.name和this.route.query.name和this.route.params.name。
query更加类似于我们ajax中get传参,params则类似于post,前者在浏览器地址栏中显示参数,后者则不显示