template
table表头需要添加max-height这个属性
table表头需要添加max-height这个属性
<el-table :data="tableData" :max-height="tableHeight"></el-table>
data
watch
created
data
setTableHeight:window.innerHeight
setTableWidth:window.innerWidth
setTableWidth:window.innerWidth
setTableHeight(params){
this.getHeight(params)
}
setTableWidth(params){
this.getWidth(params)
}
mounted
const that = this
window.onresize =() =>{
return (()=>{
window.screenHeight = window.innerHeight
this.setTableHeight = window.screenHeight;
//宽度
//宽度
// window.screenWidth = window.innerWidth
// this.setTableWidth = window.screenWidth;
})()
}
created
this.getHeight(this.setTableHeight)
methods
methods
//获取屏幕高度改变表格高度
getHeight(params){
if(params <= 723){
this.tableHeight = (350 - (723 - params))
}else if(params <= 804 && params > 723){
this.tableHeight = (430 - (804 - params))
}else if(params <= 904 && params > 804){
this.tableHeight = (530 - (904 - params))
}else if(params <= 964 && params > 904){
this.tableHeight = (590 - (964 - params))
}
}
//获取屏幕宽度改变表格高度
getWidth(params){
if(params<= 1536){
this.tableHeight = 350
}else if(params<= 1707 && params> 1536){
this.tableHeight = 430
}else if(params<= 1920 && params> 1707){
this.tableHeight = 530
}else if(params<= 2048 && params> 1920){
this.tableHeight = 590
}
}