侧边栏壁纸
博主头像
小鱼吃猫博客博主等级

你所热爱的,便是你的生活。

  • 累计撰写 113 篇文章
  • 累计创建 47 个标签
  • 累计收到 9 条评论

目 录CONTENT

文章目录

ElementUI 表格自适应高度终极解决方案

小鱼吃猫
2022-09-19 / 0 评论 / 0 点赞 / 178 阅读 / 572 字

@[TOC](ElementUI 表格自适应高度终极解决方案)
直接上代码,这样不管在表格上边有任何组件,都可以解决。下边的这个50高度是用来放其他组件的,比如常见的分页组件,如果你不需要的话,可以不用放。

    this.$nextTick(function () {
    //在页面渲染完成后
      this.height = window.innerHeight - this.$refs.table.$el.getBoundingClientRect().top - 50     
      this.$refs.table.$el.getBoundingClientRect().top //表格距离浏览器的高度
      var that = this
      // 添加监听窗口大小变化事件
      window.onresize = function () {
        that.height = window.innerHeight - that.$refs.table.$el.getBoundingClientRect().top - 50
      }
    })
0

评论区