码迷,mamicode.com
首页 > Web开发 > 详细

vue使用JS的形式进行路由导航

时间:2019-02-16 19:28:14      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:his   pat   导航   命名   pre   参数   route   color   style   

// 注意: 一定要区分 this.$route 和 this.$router 这两个对象,
      // 其中: this.$route 是路由【参数对象】,所有路由中的参数, params, query 都属于它
      // 其中: this.$router 是一个路由【导航对象】,用它 可以方便的 使用 JS 代码,实现路由的 前进、后退、 跳转到新的 URL 地址

      console.log(this);
      // 1. 最简单的
      // this.$router.push("/home/goodsinfo/" + id);
      // 2. 传递对象
      // this.$router.push({ path: "/home/goodsinfo/" + id });
      // 3. 传递命名的路由
      this.$router.push({ name: "goodsinfo", params: { id } });
{ path: ‘/home/goodsinfo/:id‘, component: GoodsInfo, name: ‘goodsinfo‘ },

 

vue使用JS的形式进行路由导航

标签:his   pat   导航   命名   pre   参数   route   color   style   

原文地址:https://www.cnblogs.com/kangkang-saonian/p/10388838.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!