Vue 实现页面跳转

toIndex: function(){
  this.$router.push("/?linkParam="+ localStorage.getItem("id"));
}

this.$router.push()方法只有一个参数的时候,代表跳转地址,还可以增加参数传值。

写法:

this.$router.push({name: "toLink", params: {'id': data.id, 'title': data.title}});

接收参数:

this.$route.params.title

注:

path 不能和 params 一起使用,否则 params 将无效。需要用 name 来指定页面。

或者通过 path 和 query 传递参数

this.$router.push({path: 'toLink', query: {'id', this.id}})

接收参数:

this.$route.query.id

 

posted @ 2020-10-16 11:20  格鲁特baby  阅读(272)  评论(0编辑  收藏  举报