vue+elementUI实现固定table超过设定高度显示下拉条

解决方案:

在表格上添加了style="height: px;":max-height="",这两个设置共同作用使表格在内容超过 设定高度时显示滚动条配合css使用

高度值可根据实际需求调整

复制代码
<el-table
  :data="biddData"
  style="width: 100%; margin-top: 10px; height: 900px;"
row-key="id"
:border="false"
lazy
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
class="horizontal-line-table table-scroll"
:header-cell-style="{background:'#42b983', color: '#ffffff'}"
@selection-change="handleSelectionChange"
ref="multipleTable"
:max-height="900">
<el-table-column
  type="selection"
  align="center"
  width="50">
</el-table-column>
<el-table-column
  prop="mlname"
  label="名称"
  width="300">
  <template slot-scope="scope">
    <el-button
      v-if="scope.row.filecode === '1'"
      type="text"
      @click="handleClick(scope.row)">
      {{ scope.row.mlname }}
    </el-button>
    <span v-else>{{ scope.row.mlname }}</span>
  </template>
</el-table-column>
<el-table-column
  prop="filetype"
  align="center"
  label="文件分类">
</el-table-column>
<el-table-column
  prop="createtime"
  align="center"
  label="上传日期">
</el-table-column>
</el-table>
复制代码
/* 表格滚动样式 */
.table-scroll {
  .el-table__body-wrapper {
    overflow-y: auto; /* 垂直滚动 */
    max-height: 900px; /* 与表格max-height保持一致 */

    /* 滚动条美化 (可选) */
    &::-webkit-scrollbar {
      width: 6px;
    }
    &::-webkit-scrollbar-thumb {
      background-color: #ccc;
      border-radius: 3px;
    }
    &::-webkit-scrollbar-track {
      background-color: #f5f5f5;
    }
  }

  /* 处理树形表格展开图标对齐问题 */
  .el-table__expand-column {
    vertical-align: middle !important;
  }
}
相关推荐
Nan_Shu_61413 分钟前
学习:入门uniapp Vue3组合式API版本(17)
前端·vue.js·学习·uni-app
止观止44 分钟前
Remix框架:高性能React全栈开发实战
前端·react.js·前端框架·remix
萌萌哒草头将军1 小时前
🚀🚀🚀 深入探索 Node.js v22.18.0 新特性;默认支持运行 ts 文件了!
前端·typescript·node.js
安心不心安1 小时前
React ahooks——副作用类hooks之useThrottleFn
前端·javascript·react.js
秋田君1 小时前
Vue3 + WebSocket网页接入弹窗客服功能的完整实现
前端·javascript·websocket·网络协议·学习
浪里行舟2 小时前
一网打尽 Promise 组合技:race vs any, all vs allSettled,再也不迷糊!
前端·javascript·vue.js
Antonio9152 小时前
【网络编程】WebSocket 实现简易Web多人聊天室
前端·网络·c++·websocket
tianzhiyi1989sq3 小时前
Vue3 Composition API
前端·javascript·vue.js
今禾3 小时前
Zustand状态管理(上):现代React应用的轻量级状态解决方案
前端·react.js·前端框架
用户2519162427113 小时前
Canvas之图形变换
前端·javascript·canvas