使用Elementui的table的固定列时,出现拖动条被固定列遮挡的情况,加入下面方法可以适应屏幕比例,让固定列的高度随着表格高度变化
mounted() {
window.addEventListener("resize", this.tableHeight);
},
beforeDestroy() {
window.removeEventListener("resize", this.tableHeight);
},
tableHeight() {
this.maxHeight = document.body.clientHeight * 0.72;
this.$nextTick(() => {
var fix = document.getElementsByClassName("el-table__fixed")[0];
var fixStyle = fix.getAttribute("style");
var heightLocation = fixStyle.indexOf("height");
var modifyFixStyle = fixStyle
.substring(0, heightLocation)
.concat("height: ")
.concat(`${this.maxHeight * 0.98}`)
.concat("px;");
fix.setAttribute("style", modifyFixStyle);
});
},