动态获取搜索栏的高度,设置table高度

当页面搜索条件太多,屏幕分辨率由1920变为1366时,搜索模块高度发生变化,需要通过计算获取高度和表格设置高度,


image.png

image.png

代码实现

<template>
<div>
<div class="search"  ref="search" id="search">
  ......
  </div>
<div  :style=" table_right3">

          <el-table :data="activeTableData1" style="width:100%;" 
             :row-key="getRowKey" height="95%"
                        :header-cell-style="{'background-color':'#ebeef54a'}">
......
</el-table>
</div>
</div>
</template>
<script>
export default {
data(){
  return {
       elementHeight:0,
       table_right3:{}
  }
},
  mounted() {
    this.searchheight()

  },
  methods: {
      //获取 searchheight
      searchheight(){
        let that = this
        setTimeout(()=>{
          that.elementHeight = document.getElementById('search').offsetHeight
          let elementHeight = 240+that.elementHeight
          that.table_right3 = {
            'margin-top':'10px',
              'height': `calc(96vh - ${elementHeight}px)`
          }
        },100)
      },
  }
}
</script>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容