vue超链接传值、查看页面以及父子传值

vue超链接传值、查看页面以及父子传值_第1张图片

      
      
      

router-link 这里需要去/src/router/index.js里面配置

  {
    path: '/equipment/electrical-data',
    component: Layout,
    hidden: true,
    permissions: ['equipment:electrical:list'],
    children: [
      {
        path: 'index/:electricalId(\\d+)',
        component: () => import('@/views/equipment/electrical/electri'),
        name: 'Data',
        meta: { title: '电表详情', activeMenu: '/equipment/electrical' }
      }
    ]
  },

跳转过来是这样的查看页面 :column 是对应的几列展示
在这里插入图片描述


      
        
        {{form.electricalName}}
      
      
        
        
      

    

这里是获取$route路由传过来的值

  created() {
    const electricalId = this.$route.params && this.$route.params.electricalId;
  },

##父子传值
父:方法绑定按钮 传入队友的值 直接就携带值跳转到对应路由

    getBillInfo(row,type){
      const electricalId = row.electricalId || this.ids
      this.$router.push({ path: '/finance/bill', query: { electricalId: electricalId,proprietorPayType:type } }) // 跳转到B
    },

子:直接路由.query属性就能获取

  created() {
    console.log(this.$route.query);
    this.queryParams.proprietorPayType=this.$route.query.proprietorPayType;
    this.queryParams.electricalId=this.$route.query.electricalId;
    this.getList();
  },

你可能感兴趣的:(vue.js,javascript,ecmascript,ruoyi)