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;
  }
}
相关推荐
yivifu几秒前
Excel中Lookup函数实现临界点归入下一个等级的方法
java·前端·excel
Wiktok1 分钟前
Tailwind CSS 自适应相关
前端·css·tailwindcss
LYFlied2 分钟前
【一句话概括】Vue2 和 Vue3 的 diff 算法区别
前端·vue.js·算法·diff
亮子AI6 分钟前
Chrome 和 Edge 生成的 fingerprint 是一样的?
前端·chrome·edge
狼性书生7 分钟前
uniapp实现的时间范围选择器组件
前端·uni-app·vue·组件·插件
挫折常伴左右13 分钟前
HTML中的表单
前端·html
天问一15 分钟前
前端引用printJS打印
前端·arcgis
哆啦A梦158818 分钟前
商城后台管理系统 04 登录-功能实现-数据持久化-vuex
javascript·vue.js·elementui
xinyu_Jina1 小时前
PaperStudio:WYSIWYG文档的Web实现——从CSS Print到客户端PDF生成的技术解析
前端·css·pdf
默默学前端1 小时前
html列表标签及css列表属性
前端·css·html5