el-table 固定前n行 配合 max-height 生效

:row-class-name="TableRowClassName" 加上类名

javascript 复制代码
   <el-table
        :data="computedTableList"
        border
        style="width: 100%"
        :row-class-name="TableRowClassName"
        max-height="800">
        <el-table-column fixed prop="name" align="center" width="185" :key="1">
 </el-table>

  function TableRowClassName ({ row, rowIndex }) {
    if (row.isFalseData) {
      return 'top_bgc fixed-row'
    }
    if (row.isSticky) {
      return 'sticky_bgc'
    }
  }


  // 顶部固定 悬浮
  :deep(.el-table tr.el-table__row.fixed-row) {
    position: sticky; //粘性定位
    position: -webkit-sticky;
    z-index: 999;
  }
  :deep(.el-table tr.el-table__row.fixed-row:nth-of-type(1)) {
    top: 0;  
  }
  :deep(.el-table tr.el-table__row.fixed-row:nth-of-type(2)) {
    top: 94px;  // 根据每一行的高度自行调整
  }
  :deep(.el-table tr.el-table__row.fixed-row:nth-of-type(3)) {
    top: 188px;
  }
相关推荐
北城笑笑1 小时前
Vue 110 ,若依SSE流式接口限次空500排查与解决
前端·javascript·vue.js·后端·vue
Patrick_Wilson2 小时前
构建通过了,为什么有些浏览器还会白屏?
前端·javascript·浏览器
AI前端工程狮4 小时前
我把 MCP 长任务拆成三个工具,token 账单涨了 7 倍
javascript·人工智能·程序员
mONESY5 小时前
DeepAgents 从零上手:别再手搓 Harness,用中间件拼出一个调研团队
javascript
吴长建先生重名了5 小时前
一次线上MySQL慢查询Bug的复现与调优全过程
javascript
LVZ7 小时前
AI Agent 缺的不是更强的模型,而是一个运行时
前端·javascript·后端
1-1=07 小时前
Vue 中 Class 与 Style 绑定
前端·javascript·vue.js
闲来没事抠鼻屎7 小时前
Web打印批量出单:vue-print-designer 千页实测
vue.js
用户83134859306987 小时前
Vue3的v-if /v-show/v-else /v-else-if:区别、渲染原理、坑点与性能选型
前端·javascript·vue.js
Bigger7 小时前
别再手搓调色板了:Vue 3 一个组件搞定纯色、渐变和画布吸管取色
前端·vue.js·数据可视化