el-table拆分单元格

el-table的官方文档给出了合并单元格的方法,本以为拆分和合并是一样的,但是tableData遍历出一条数据在表格中就添加一行,而现在是要根据这一条数据里面的数据把这一行拆分称两行或多行,这样貌似是行不通的。然后我看别的写的相关文章,就是给要拆分的单元格里面写一个表格,然后添加CSS样式,让表格看起来是被拆分的效果。

<el-table border isIndex :tableColumn="tableColumn" :tableData="tableData">
	<template #count="{row}">
         <div class="annotations">
              <tr class="annotation-rs cluster-rs" v-for="(item,index) in row.replicas" :key="index">
                  <td>{{item.key}}: {{item.value}}</td>
              </tr>
         </div>
    </template>
</el-table>

data(){
	tableColumn: [
        {
          label: "名称",
          prop: "name",
          align: "center",
        },
        {
          label: "命名空间",
          prop: "space",
          align: "center",
        },
        {
          label: "实例数",
          prop: "replicas",
          align: "center",
          slot: "count",
        },
        {
          label: "集群tag",
          prop: "annotations",
          slot: "tag",
          align: "center"
        },
        {
          label: "集群资源",
          prop: "clusterRs",
          slot: "rs",
          align: "center"
        },
    ],
    tableData: [],
}

methods:{
	async getList() {
      this.loading = true;
      const res = await getClusterList();
      this.tableData = res.list;
  }
}

<style lang="scss">
  .cluster-rs {
    text-align: center;
  }
  .annotation-rs{
    width: 100%;
    height: 100%;
    border: none;
    td{
      width: 155px;
      padding: 5px;
      border-right: none;
      text-align: center;
      vertical-align: middle;
    }
  }
  tr:last-child{
    td{
      border-bottom: none;
    }
  }
</style>

在这里插入图片描述

  • 5
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值