1.表格自适应高度,有两种方法,
方法一:外部div定死一个高度,里面的table的高度定位百分比,也就是基于最外层的div的高度的百分比。缺点是:只能适应本电脑分辨率或者小于本电脑的分辨率,大于本电脑的分辨率,就会出现不一样的效果。
方法二(推荐)使用window.innerHeight来计算高度。紧接着就 ,以及减去其他的高度乘以根字体的大小再除于100
优点是兼容高低分辨率
方法一
<div class="container">
<el-table height="90%">
</el-table>
</div>
<style scope>
.container{
height:400px;
}
</style>
方法二
computeHeight() {
computed: {
computeHeight() {
let resolute = this.$store.state.global.htmlFontSize
let h = window.innerHeight - (350 * resolute) / 100
return h
}