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>
相关推荐
2501_920931703 小时前
React Native鸿蒙跨平台采用ScrollView的horizontal属性实现横向滚动实现特色游戏轮播和分类导航
javascript·react native·react.js·游戏·ecmascript·harmonyos
东东5165 小时前
智能社区管理系统的设计与实现ssm+vue
前端·javascript·vue.js·毕业设计·毕设
catino5 小时前
图片、文件的预览
前端·javascript
2501_920931706 小时前
React Native鸿蒙跨平台实现推箱子游戏,完成玩家移动与箱子推动,当所有箱子都被推到目标位置时,玩家获胜
javascript·react native·react.js·游戏·ecmascript·harmonyos
AI老李7 小时前
PostCSS完全指南:功能/配置/插件/SourceMap/AST/插件开发/自定义语法
前端·javascript·postcss
方也_arkling7 小时前
Element Plus主题色定制
javascript·sass
晓晓莺歌7 小时前
vue3某一个路由切换,导致所有路由页面均变成空白页
前端·vue.js
2601_949809597 小时前
flutter_for_openharmony家庭相册app实战+我的Tab实现
java·javascript·flutter
Up九五小庞7 小时前
开源埋点分析平台 ClkLog 本地部署 + Web JS 埋点测试实战--九五小庞
前端·javascript·开源
摘星编程8 小时前
React Native + OpenHarmony:UniversalLink通用链接
javascript·react native·react.js