只需要在table 里面增加height,这样就是固定高度的固定表头;
<el-table height="600px">
动态增加表格高度的固定表头,就需要动态设置表格的高度;
<el-table :height="tableHeight">
// 在watch里面观察数组的长度,然后计算高度
watch: {
'tableData': {
handler(newVal){
if(newVal){
this.tableHeight = this.tableData.length * 37 + 100 > 600 ? 600 :this.tableData.length * 37 + 100
}
},
deep: true,
immediate: true
}
},