关于el-table 流体高度随着页面大小 自适应

257 阅读1分钟

通过监听dom 元素高度的变化 给 maxHeight 动态赋值 :key =maxHeight 来实现实时更新组件

    <div id="midTable">
        <ai-table :columns="columns" :tableData="data" :maxHeight="maxHeight" :key="maxHeight">
          <template #action >
            <div class="midBox">
              <div class="midDetail">
                详情>>
              </div>
            </div>
          </template>
        </ai-table>
    </div>
    
    mounted() {
    this.$nextTick(()=>{
      this.timer = setInterval(() =>{
        this.maxHeight =  document.getElementById("midTable").offsetHeight
      },100)
    })
    
  },