Vue + ant design 实现嵌套子表格

Table - 嵌套子表格

一、效果展示

功能1:添加主表格一行
功能2:添加某个子表格一行
功能3:子表格数据的异步加载

在这里插入图片描述
在这里插入图片描述

二、代码实现

<template>
  <div>
    <a-button @click="add" type="primary" size="small" style="margin:20px">添加主表格数据</a-button>
    <a-table
      :columns="columns"
      :data-source="data"
      class="components-table-demo-nested"
      @expand="getInnerData"
      @expandedRowsChange="expandedRowsChange"
      style="margin:20px"
    >
      <a slot="operation" slot-scope="row" @click="addInnderData(row)">添加子表格数据</a>
      <a-table
        slot="expandedRowRender"
        slot-scope="inner"
        :columns="innerColumns"
        :data-source="inner.innerData"
        :pagination="false"
      >
        <span slot="operation" slot-scope="text" class="table-operation">
          <a-dropdown>
            <a-menu slot="overlay">
              <a-menu-item>Action 1</a-menu-item>
              <a-menu-item>Action 2</a-menu-item>
            </a-menu>
            <a>
              More
              <a-icon type="down" />
            </a>
          </a-dropdown>
        </span>
      </a-table>
    </a-table>
  </div>
</template>
<script>


const columns = [
  {
    title: 'Name', dataIndex: 'name', key: 'name' },
  {
    title: 
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值