$router和$route的区别

学习分享 5年前 (2018) bestcyt
30 0 0
  • $router

$router是编程式导航,this.$router.push(‘要跳转的路径名’),还有this.$router.go(-1)返回上一页面。

  • $route

vue2.0里页面参数是 this.$route.query或者 this.$route.params 接收router-link传的参数,
$route为当前router跳转对象里面可以获取name、path、query、params等。

// 存放商品 id,数量的对象
const payload = {
      goodsId:this.$route.params.goodsId,
      count:this.goodsCount
 }

 

版权声明:bestcyt 发表于 2018年10月15日 pm4:06。
转载请注明:$router和$route的区别 | 爱前端导航

相关文章

联系站长