当前位置: 首页 > Web前端 > vue.js

vue路由参数的传递以及如何获取

时间:2023-03-31 14:27:44 vue.js

路由参数//类似get请求,地址栏显示参数1.this.$router.push({path:'/about',query:{id:1}});//类似get请求,地址栏显示参数2.this.$router.push({name:'about',query:{id:1});//推荐,类似post请求,address栏不显示参数,没有参数大小限制3.this.$router.push({name:'about',params:{id:1}});注意:查询参数params参数的值在使用path时可以正常获取,在地址栏显示参数,类似get不能正常获取,值为空且使用name时可以正常获取,显示地址栏中的参数,类似get值可以正常获取,地址栏不显示参数,类似post路由获取参数1.this.$route.query2.this.$route.params