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;
  }
}
相关推荐
默恋~微凉7 分钟前
shell(八)——WEB与Nginx
开发语言·前端·php
要加油哦~17 分钟前
nrm | npm 的镜像管理工具
前端·npm·node.js·nrm
想不明白的过度思考者18 分钟前
基于 Spring Boot 的 Web 三大核心交互案例精讲
前端·spring boot·后端·交互·javaee
孟祥_成都18 分钟前
不易懂你打我!写给前端和小白的 大模型(ChatGPT) 工作基本原理!
前端·人工智能
恋猫de小郭23 分钟前
回顾 Flutter Flight Plans ,关于 Flutter 的现状和官方热门问题解答
android·前端·flutter
●VON23 分钟前
从零开始:用 Electron 构建你的第一个桌面应用
前端·javascript·electron
艾小码25 分钟前
从源码到npm:手把手带你发布Vue 3组件库
前端·vue.js·npm
张风捷特烈30 分钟前
FlutterUnit3.4.1 | 来场三方库的收录狂欢吧~
android·前端·flutter
乔冠宇1 小时前
CSS3中的新增属性总结
前端·javascript·css3
e***58231 小时前
Spring Cloud GateWay搭建
android·前端·后端