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;
  }
相关推荐
Aric_Jones34 分钟前
JavaScript 从入门到精通:完整语法指南
开发语言·javascript·ecmascript
西门吹-禅3 小时前
文本搜索node js--meilisearch
开发语言·javascript·ecmascript
问今域中4 小时前
Vue的computed用法解析
前端·javascript·vue.js
扶苏10025 小时前
详解Vue3的provide和inject
前端·javascript·vue.js
奋斗吧程序媛6 小时前
Vue3初体验(2)
前端·javascript·vue.js
FunW1n7 小时前
tmf.js Hook Shark框架相关疑问归纳总结报告
java·前端·javascript
henry1010108 小时前
Deepseek辅助生成的HTML5网页版抄经典《弟子规》
前端·javascript·css·html·html5
一 乐8 小时前
林业资源管理|基于java + vue林业资源管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·林业资源管理系统
扶苏10028 小时前
深入 Vue 3 computed:原理、实战与避坑指南
前端·javascript·vue.js
高德开放平台9 小时前
高德开放平台JS API插件支持WebMCP:重新定义AI与网页交互的新时代
javascript·人工智能·开发者·高德地图