vue 基于element组件库实现表格下多个子级展示

实现效果

<template>
  <div class="content-right-table">
    <el-table
      ref="tableData"
      :data="tableData"
      tooltip-effect="light"
      style=" 100%"
      @expand-change="handle_list"
    >
      <el-table-column prop="children" type="expand" width="100">
        <template slot-scope="slots">
          <el-table
            ref="subTableData"
            :data="slots.row.children"
            tooltip-effect="light"
            @expand-change="handle_subList"
          >
            <el-table-column prop="children" type="expand" width="100">
              <template slot-scope="scopes">
                <el-table ref="secSubTableData" :data="scopes.row.children" tooltip-effect="light">
                  <el-table-column prop="portNumber" label="编号" />
                  <el-table-column prop="name" label="名称" />
                  <el-table-column prop="ip" label="IP" />
                  <el-table-column label="操作" width="200">
                    <template slot-scope="scope">
                      <el-button type="text" class="primary-text" @click="handle_edit(scope.row)">编辑</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </template>
            </el-table-column>
            <el-table-column prop="number" label="编号" />
            <el-table-column prop="size" label="大小" />
            <el-table-column label="操作" width="200">
              <template slot-scope="scope">
                <el-button type="text" class="danger-text" @click="handle_delete(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </template>
      </el-table-column>

      <el-table-column label="ID" show-overflow-tooltip>
        <template slot-scope="scope">{{ scope.row.rtuId }}</template>
      </el-table-column>
      <el-table-column label="名称" show-overflow-tooltip>
        <template slot-scope="scope">
          <div @click="handle_jump(scope.row)">
            <span size="medium">{{ scope.row.name }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="count" label="数量" />
    </el-table>
  </div>
</template>
js部门
tableData: [
        {
          rtuId: '4564651',
          children: [
            {
              children: [
                {
                  portNumber: '001',
                  name: '001',
                  ip: '001',
                  portNumber: '001',
                },
              ],
              number: 132123,
              size: 1231231,
            },
          ],
          name: 'fdsf',
          count: '123121',
        },
        {
          rtuId: '4564651',
          children: [
            {
              children: [
                {
                  portNumber: '001',
                  name: '001',
                  ip: '001',
                  portNumber: '001',
                },
              ],
              number: 132123,
              size: 1231231,
            },
          ],
          name: 'fdsf',
          count: '123121',
        },
      ],
样式比较丑,大家需要的自己调整
原文地址:https://www.cnblogs.com/j-j-h/p/13691605.html