1.this.$route.query的使用
params、query是什么?
params:/router1/:id ,/router1/123,/router1/789 ,这里的id叫做params
query:/router1?id=123 ,/router1?id=456 ,这里的id叫做query。
首先我们先看看路由index.js的定义
传参数如下:
this.$router.push('/productdetail?id='+id) //注意这里路由没有带/:id
接收参数:
console.log(this.$route) //打印出来
即接收值
this.$route.query.id获取参数
跳转后页面路径如下
this.$route.params的使用
传参数如下:
this.$router.push("/branddetail/" + item.id); //这里注意路由定义带了/:id
接收参数如下:
老规矩先打印console.log(this.$route)
this.$route.params.id 获取到值
跳转后页面路径如下:
本文到这里就结束了,写的不好的地方,请各位大佬们见谅。以上就是本文的全部内容,希望对大家的学习有所帮助,谢谢大佬们呀