当前位置:   article > 正文

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

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

在这里插入图片描述

      <el-table-column label="电表编码" align="center" width="120" prop="electricalNum" >
      <template slot-scope="scope">
        <div style="text-align: left">
        <router-link :to="'/equipment/electrical-data/index/' + scope.row.electricalId" class="link-type">
          <span>{{ scope.row.electricalNum }}</span>
        </router-link>
          <div style="white-space:nowrap">初始表码: <span style="color: #1348ce;">{{ scope.row.electricalInitNum}}</span>&nbsp;</div>
          <div style="white-space:nowrap">结算表码: <span style="color: #1348ce;">{{ scope.row.electricalEndNum}}</span>&nbsp;</div>
        </div>
      </template>
      </el-table-column>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

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' }
      }
    ]
  },
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

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

<el-descriptions class="margin-top" title="电表详情" :column="3" :size="'mini'" border>
      <el-descriptions-item>
        <template slot="label">
          电表名称
        </template>
        {{form.electricalName}}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">
          电表品牌
        </template>
        <dict-tag :options="dict.type.sys_meter_brand" :value="form.electricalBrand"/>
      </el-descriptions-item>

    </el-descriptions>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

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

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

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

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

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

  created() {
    console.log(this.$route.query);
    this.queryParams.proprietorPayType=this.$route.query.proprietorPayType;
    this.queryParams.electricalId=this.$route.query.electricalId;
    this.getList();
  },
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/45515
推荐阅读
相关标签
  

闽ICP备14008679号