惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
Martin Fowler
Martin Fowler
爱范儿
爱范儿
IT之家
IT之家
Last Week in AI
Last Week in AI
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
aimingoo的专栏
aimingoo的专栏
G
Google Developers Blog
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
The Cloudflare Blog
MyScale Blog
MyScale Blog
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog

博客园 - VipSoft

FastAPI 全局 HTTP 异常处理器 + 统一响应封装 SpringBoot 心跳日志不记录 access.log Qdrant Linux 安装(非Docker) LangChain — RAG 知识库(实操) LangChain — RAG 构建知识库(理论) LangChain — RAG 构建知识库(实操) Python PyCharm 运行,取不到 .env 文件中的值 Qdrant 安装(Windows) LangChain — RAG 构建知识库 Python 项目简单部署(Linux) MinerU - 将非结构化文档(PDF、图片、Office 文件等)转换为机器可读的 Markdown 和 JSON LangChain 入门 服务端部署-FastAPI LangChain 入门 LangSmith LangChain 入门 实战 - 食谱推荐 LangChain 入门 Memory 会话记忆 LangChain 入门 Tools 工具 LangChain 入门 Tools 工具 LangChain 入门 Prompts 提示词 LangChain 入门 Message 消息 LangChain 入门 Model 的初始化和调用 LangChain 入门 Agent 的基本运行机制 AI 0基础学习,名词解析 LangChain 和 LangGraph AI大模型知识体系 Dify — Workflow - 数据可视化 Dify — 连接MySQL配置 Dify — Chatflow - 数据库智能查询 Dify — Chatflow - 文档知识库 Dify — Agent 智能体 高安全券码、注册码生成
Vue - el-table 嵌套表
VipSoft · 2026-01-09 · via 博客园 - VipSoft

使用 el-table 实现表格嵌套效果

<template>
  <el-card shadow="never">
    <el-table :data="tableData" border class="detail-table">
      <el-table-column prop="ReportTitleName" label="名称" width="120" />
      <el-table-column prop="detail" label="明细" class-name="detail-column">
        <template #default="scope">
          <table class="inner-table">
            <tbody>
              <tr v-for="(item, index) in scope.row.Price" :key="index">
                <td class="inner-td">{{ item.MonitorHour }}小时</td>
                <td class="inner-td">{{ item.Price }}元</td>
              </tr>
            </tbody>
          </table>
        </template>
      </el-table-column>
      <el-table-column
        v-hasPerm="'DeviceAdd'"
        width="130"
        fixed="right"
        label="操作"
        prop="describe"
      >
        <template #default="scope">
          <el-button
            type="primary"
            icon="edit"
            link
            size="small"
            @click="handleOpenEditDialog(scope.row)"
          >
            编辑
          </el-button>
          <el-button
            type="primary"
            icon="edit"
            link
            size="small"
            @click="handleOpenRemarkDialog(scope.row)"
          >
            备注
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script setup>
import { ref } from "vue";

const tableData = ref([
  {
    TitleLevel: 11,
    ReportTitleName: "张三",
    Price: [
      { MonitorHour: 24, Price: 0.01 },
      { MonitorHour: 72, Price: 0.02 },
      { MonitorHour: 168, Price: 0.03 },
    ],
  },
  {
    TitleLevel: 21,
    ReportTitleName: "李四",
    Price: [
      { MonitorHour: 24, Price: 0.1 },
      { MonitorHour: 72, Price: 0.2 },
      { MonitorHour: 168, Price: 0.3 },
    ],
  },
]);
</script>

<style scoped>
/* 只针对明细列的表头 */
:deep(.detail-column.is-leaf) {
  padding: 0 !important;
}

/* 只针对明细列的单元格 */
:deep(.detail-column) {
  padding: 0 !important;
}

/* 内部表格样式 */
.inner-table {
  width: 100%;
  border-collapse: collapse;
  margin: -1px; /* 消除双边框重叠 */
}

.inner-td {
  width: 50%;
  border: 1px solid #ebeef5;
  padding: 8px 10px;
  text-align: center;
  height: 40px;
  box-sizing: border-box;
}

/* 调整内部表格边框,避免重复 */
.inner-table tr:last-child td {
  border-bottom: none;
}

.inner-table td:last-child {
  border-right: none;
}

/* 确保明细列内容区域没有内边距 */
:deep(.detail-column .cell) {
  padding: 0 !important;
  line-height: normal;
}

/* 保持名称列的正常内边距 */
:deep(.el-table__cell:not(.detail-column)) {
  padding: 8px 0 !important; /* 正常的内边距 */
}

:deep(.el-table__cell:not(.detail-column) .cell) {
  padding: 0 10px !important; /* 正常的内边距 */
}
</style>

效果如下
image