vue-路由传参

路由的传参接收方式统一在this.$route里面


动态路由传值
在路由的配置项path中,设定传递参数的属性 方式为 /:属性.....
在路由跳转的属性中 设置属性的值 方式为 /detail/0/苹果

接收:this.$route.params

query传值
query传值?后面的参数 &进行链接 /user?name=zhangsan&age=18


传值的方式:通过?进行数据的拼接 每个字段之间用&分隔 类似与get请求的方式
接收:this.$route.query


区别:query传值是非必须传值 动态路由传值是必须要传值

动态路径接收方式

let {id,name} = this.$route.params;
this.id = id;
this.name = name;

  query传值接收方式  

 let {id,name} = this.$route.query;
            this.id = id;
            this.name = name;

  

原文地址:https://www.cnblogs.com/aaa1122331/p/10595797.html