iview table 自适应高度

// 思路:1.在iview-table的外层定义一枚父元素,对父元素的高度做响应式处理
//      2.mouted阶段,获取父元素高度并赋给iview-table,且设置window.resize事件也触发此方法


// 示例:
<div>
    <div class="custom-head"></div>
    <div class="custom-body">
        <i-table v-bind:columns="" v-bind:data="" size="small" v-bind:height="tableHeight" stripe border></i-table>
    </div>
</div>



.custom-body {
    height: calc(100vh - 305px);
}

.ivu-table-tip {
    overflow-x:hidden;
}



mounted() {
    let _this = this;
    this.setTableHeight();
    window.onresize = () => {
        _this.setTableHeight();
    }
},



methods: {
    setTableHeight() {
        this.tableHeight = parseInt($(".custom-body").css("height"));
    }
}

 

posted @ 2021-08-17 15:21  最好的年纪  阅读(1212)  评论(0编辑  收藏  举报