• Vue---this.$route和this.$router这两个对象--都需要在router.js 中配置


    // 注意: 在 this 这个组件身上,有 this.$route 和 this.$router

    // this.$route 是专门用来获取路由中参数的;

    // this.$router 是专门来实现编程式导航的;

    // 注意:this.$route和this.$router这两个对象

    // this.$route是路由参数对象,所有路由中的参数,params,query都属于他

    // this.$router 是一个路由(导航对象),用它方便的使用js 代码,实现路由的前进,后退,跳转到新的url地址

     

    1.最简单的

    点击事件--@click="goDesc"

    methods: {
      
       goDesc() {
         this.$router.push("路径/home/goodsdesc/" + 参数this.goodsinfo.id);
      }
    }
     rputer.js--配置
    { path: '/home/goodsinfo/:id', component: GoodsInfo, props: true },
     2.首页tbar跳转---
    标签跳转<router-link class="" to="路径/home"></router-link>
    需要在router.js配置路由
    <router-link tag="div" :to="'/home/goodsinfo/' + item.id" class="goods-item" v-for="item in goodslist" :key="item.id">
     接收:data(){
      return{
        id:this.$route.params.id
      }
    }
    3.在router.js中国配置路由的时候给组件定义名字属性
    // 启用 props 来接收路由的参数
    { path: '路径/home/goodscomment/:id', component: 文件名字GoodsComment, props: true, name: '定义的名字goodscmt' }
     this.$router.push({
            name: "goodscmt",
            params: { id: this.goodsinfo.id }
          });
     
  • 相关阅读:
    Java之美[从菜鸟到高手演变]之设计模式
    常见JAVA框架
    每周一荐:学习ACE一定要看的书
    YUV格式&像素
    关于makefile
    socket通信
    [理论篇]一.JavaScript中的死连接`javascript:void(0)`和空连接`javascript:;`
    [应用篇]第三篇 JSP 标准标签库(JSTL)总结
    [应用篇]第一篇 EL表达式入门
    KVM基本实现原理
  • 原文地址:https://www.cnblogs.com/fdxjava/p/11645704.html
Copyright © 2020-2023  润新知