//通过 :height="tableHeight" 设置
<el-table>
:height="tableHeight"
ref="multipleTable"
:data="tableData"
tooltip-effect="dark"
class="tab_info"
style="width: 100%"
default-expand-all
row-key="id"
:row-class-name="tableRowClassName"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
@selection-change="handleSelectionChange"
v-loading="loading"
</el-table>
export default {
data() {
return {
tableHeight:500 , // 自己设置高度
}
},
mounted() {
//固定表头
this.$nextTick(function() {
this.tableHeight =
window.innerHeight - this.$refs.table.$el.offsetTop - 50;
// 监听窗口大小变化
let self = this;
window.onresize = function() {
self.tableHeight =
window.innerHeight - self.$refs.table.$el.offsetTop - 50;
};
});
},
}
element table 表头固定,表格高度自适应
最新推荐文章于 2024-07-16 16:56:42 发布