前端动态计算高度

/**
 * @description: 动态计算表格高度
 * @return {*}
 */
onresize() {
  /* 表格最大高度=页面高度减去除表格外的高度-上下间距dialogMargin高度 */
  // 获取屏幕高度
  const { innerHeight } = window;
  // 获取类名或者id名为estimate-dialog的dom对象
  const dialog = document.querySelector('.estimate-dialog');
  const dialogWrapper = document.querySelector('.estimate-dialog-wrapper');
  const dialogStyles = window.getComputedStyle(dialogWrapper);
  // 防止该组件影响需求详情组件显示
  if (!dialogWrapper || dialogStyles.display === 'none') return;
  const header = dialog.querySelector('.el-dialog__header');
  const subTitle = dialog.querySelector('.sub_title');
  const padding = 30;
  const { showComment, appendBtn } = this.$refs;
  const headerHeight = header.clientHeight;
  const subTitleHeight = subTitle.clientHeight;
  const commentHeight = showComment.clientHeight;
  const btnHeight = appendBtn.clientHeight;
  const dialogMarin = 30;
  const height = XEUtils.sum([padding, headerHeight, subTitleHeight, commentHeight, btnHeight, dialogMarin]);
  this.tableMaxHeight = innerHeight - height;
},

mounted () {
//初始化表格
this.initializationTabColumn()
// 计算表格高度
window.onresize = (event) => {
this.onresize()
}
// 计算表格高度
this.onresize()
},

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值