其他分享
首页 > 其他分享> > iview table 自适应高度

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"));
    }
}

 

标签:setTableHeight,height,适应,window,table,custom,iview
来源: https://www.cnblogs.com/sangzs/p/15152475.html