ElementU表格组件Table高度自适应

如果你在构建管理后台,菜单栏横向摆放到整个View的顶部,下方是搜索框一些组件,然后最下面是表格来呈现数据,那么,当缩放浏览器窗口的时候,需要实现表格组件Table的高度自适应。

你可以通过如下方法实现:

setTimeout(() => {
      this.customTableHeight = window.innerHeight - this.$refs.table.$el.offsetTop;
    }, 100);

然后将customTableHeight绑定到表格组件上:

:height="customTableHeight" ref="table"

当然不要忘记在data中声明该变量。

猜你喜欢

转载自blog.51cto.com/xvjunjie/2539764