吸顶操作用到属性:position: sticky
<el-table :data="dataList"
ref="table"
:row-class-name="rowFixed"
:header-cell-class-name="rowClass"
:height="upOrDown ? 'calc(100vh - 260px)': 'calc(100vh - 140px)'">
<el-table-column label="网点" align="center" show-overflow-tooltip prop="branch_name">
</el-table-column>
</el-table>
设置表格高度后,给需要吸底的行设置定位,我这里固定的是合计行,设置了class
rowFixed ({row, rowIndex, columnIndex}) {
if (row.branch_name === '合计') {
return 'fixedRow'
}
return ''
},
注:这里的 ‘display: inline-block;’ 可有可无,根据项目自行调整
.el-table >>> .fixedRow{
/* display: inline-block; */
position: sticky;
background: #f5f7fa !important;
bottom: 0;
width: 100%;
}