// 相似于get请求,地址栏显示参数 1.this.$router.push({path:'/about',query:{id:1}}); // 相似于get请求,地址栏显示参数 2.this.$router.push({name:'about',query:{id:1}); // 推荐使用,相似于post请求,地址栏不显示参数,没有参数大小限制 3.this.$router.push({name:'about',params:{id:1}});
查询方式 | query参数 | params参数 |
---|---|---|
使用path时 | 值能正常获取,在地址栏展现参数,相似于get | 不能正常获取,值为空 |
使用name时 | 值能正常获取,在地址栏展现参数,相似于get | 值能正常获取,地址栏不展现参数,相似于post |
1.this.$route.query 2.this.$route.params