el-table表头上下显示内容

实现效果:

代码如下:

html 复制代码
 <el-table
        ref="refTable"
        :data="tableConfig.tableData"
        v-loading="tableConfig.loading"
        style="width: 100%; margin: 0 auto"
        height="100%"
        align="center"
        row-key="id"
        stripe
        size="medium"
        theme="lcs"
        border
      >
        <template v-for="(item, index) in tableConfig.viewColumns" :key="index">
          <el-table-column v-if="item.prop === 'designNoteContent'" :fixed="item.fixed" :prop="item.prop" :align="item.align" :min-width="item.width" :show-overflow-tooltip="true">
            <template #header>
              <div style="display: flex; flex-direction: column; align-items: center; line-height: 1.4">
                <span>{{ '设通号' }}</span>
                <span style="font-size: 12px; color: #606266; margin-top: 2px">DESIGN NOTE #</span>
              </div>
            </template>
            <template #default="scope">
              <a class="mc" titleContent="" @click="handleClickNoticeAppendix(scope.row)">
                {{ scope.row.designNoteContent }}
              </a>
            </template>
          </el-table-column>
          <el-table-column v-else :fixed="item.fixed" :prop="item.prop" :align="item.align" :min-width="item.width" :show-overflow-tooltip="true">
            <template #header>
              <div style="display: flex; flex-direction: column; align-items: center; line-height: 25px">
                <span>{{ getChineseLabel(item.label) }}</span>
                <span style="font-size: 12px; color: #606266; margin-top: 2px; line-height: 25px">
                  {{ getEnglishLabel(item.label) || '&nbsp;' }}
                </span>
              </div>
            </template>
          </el-table-column>
        </template>

        <el-table-column label="操作" align="center" fixed="right" min-width="180">
          <template #default="scope">
            <div class="lcs-table-button--group" style="justify-content: center">
              <div class="lcs-button-box">
                <div class="lcs-button">
                  <el-button class="elTbaleButton" link @click="handleClickInterface(scope.row)">{{ '接口' }}</el-button>
                  <el-button class="elTbaleButton" link @click="handleClickNoticeAppendix(scope.row)">{{ '详情' }}</el-button>
                  <el-button class="elTbaleButton" link style="color: #efaf41" @click="handleClickRowDel(scope.row)">{{ '移除' }}</el-button>
                </div>
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
javascript 复制代码
//表格数据
const tableConfig = reactive({
  tableData: [],
  page: 1,
  pageSize: 10,
  total: 0,
  loading: false,
  viewColumns: [
    { prop: 'issue_reason', width: '220', align: 'center', label: '发行理由ISSUE REASON', fixed: false },
    { prop: 'destination', width: '150', align: 'center', label: '目的地DEST', fixed: false },
    { prop: 'requect_section', width: '150', align: 'center', label: '请求阶段REQUEST', fixed: false }
  ],
  showMore: false
})


// 提取标签中的中文部分
const getChineseLabel = (label) => {
  if (!label) return ''
  // 提取中文部分(包括中文符号)
  const chineseMatch = label.match(/^[\u4e00-\u9fa5]+/)
  return chineseMatch ? chineseMatch[0] : label
}

// 提取标签中的英文部分
const getEnglishLabel = (label) => {
  if (!label) return ''
  // 提取英文部分(包括#符号)
  const englishMatch = label.match(/[A-Z\s#]+$/)
  return englishMatch ? englishMatch[0] : ''
}
css 复制代码
<style lang="scss" scoped>
::v-deep .el-table th.el-table__cell > .cell {
  white-space: nowrap !important;
}
::v-deep .el-table--small .el-table__cell {
  padding: 0px;
}

::v-deep .el-table .el-table__cell {
  padding: 0px;
}

::v-deep .el-table__body .el-table__cell {
  padding: 2px 0px;
}

</style>
相关推荐
拖拉斯旋风15 小时前
从零开始:使用 Ollama 在本地部署开源大模型并集成到 React 应用
前端·javascript·ollama
德育处主任15 小时前
『NAS』在群晖部署图片压缩工具-Squoosh
前端·javascript·docker
心.c15 小时前
如何基于 RAG 技术,搭建一个专属的智能 Agent 平台
开发语言·前端·vue.js
计算机学姐15 小时前
基于SpringBoot的校园资源共享系统【个性化推荐算法+数据可视化统计】
java·vue.js·spring boot·后端·mysql·spring·信息可视化
Van_captain16 小时前
rn_for_openharmony常用组件_Breadcrumb面包屑
javascript·开源·harmonyos
静听松涛13316 小时前
提示词注入攻击的防御机制
前端·javascript·easyui
澄江静如练_17 小时前
优惠券提示文案表单项(原生div写的)
前端·javascript·vue.js
C_心欲无痕17 小时前
ts - 关于Object、object 和 {} 的解析与区别
开发语言·前端·javascript·typescript
Irene199117 小时前
Vue2 与 Vue3 响应式实现对比(附:Proxy 详解)
vue.js·响应式实现
全栈前端老曹17 小时前
【包管理】read-pkg-up 快速上手教程 - 读取最近的 package.json 文件
前端·javascript·npm·node.js·json·nrm·package.json