我们在做项目时 ,经常会遇到路由跳转页面传值的问题,有的路由跳转到导航页面时 导航的样式也就改变了。
- 命名的路由(通过params)
this.$router.push({
name: "路径",
params: { type: this.type }, //传的参数
});
接受参数(可以写在created)
this.type = this.$route.params.type;
- 带查询参数,变成 /路径?selected=2
this.$router.push({
path: "路径",
query: { id: this.tid},
});
接受参数
this.clickid = this.$route.query.id;