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;
  }
}
相关推荐
你的人类朋友31 分钟前
【Node】认识一下Node.js 中的 VM 模块
前端·后端·node.js
Cosolar32 分钟前
FunASR 前端语音识别代码解析
前端·面试·github
@大迁世界3 小时前
Vue 设计模式 实战指南
前端·javascript·vue.js·设计模式·ecmascript
芭拉拉小魔仙3 小时前
Vue项目中如何实现表格选中数据的 Excel 导出
前端·vue.js·excel
jump_jump4 小时前
妙用 localeCompare 获取汉字拼音首字母
前端·javascript·浏览器
U.2 SSD4 小时前
Echarts单轴坐标系散点图
前端·javascript·echarts
德育处主任Pro4 小时前
前端玩转大模型,DeepSeek-R1 蒸馏 Llama 模型的 Bedrock 部署
前端·llama
Jedi Hongbin4 小时前
Three.js NodeMaterial 节点材质系统文档
前端·javascript·three.js·nodematerial
前端小马4 小时前
前后端Long类型ID精度丢失问题
java·前端·javascript·后端
用户1456775610375 小时前
干净的图片批量处理,处理速度飞快
前端