根据element-ui的文档,max-height的合法的值为数字或者单位为 px 的高度。无法识别响应式的css,如:
max-height:calc(100vh - 40px)
//或者
max-height:calc(100% - 40px)
通过js计算表格的最大高度,然后将高度数值传给el-table的max-height属性,上代码:
html:
<el-table ref="table" :data="info" :max-height="tableHeight">
...
</el-table>
js:
<script>
export default {
data() {
return {
tableHeight: 0
}
},
created(){
if(window.innerHeight < 1441){//3840*2160
this.tableHeight = 650;
}
if(window.innerHeight < 960){//2560*1600 || 2560*1440
this.tableHeight = 600;
}
if(window.innerHeight < 800){//1440*900
this.tableHeight = 475;
}
if(window.innerHeight < 768){//1366*768 || 1360*768
this.tableHeight = 350;
}
}
...
}
</script>