VUE 根据浏览器 获取元素高度

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/lhh143400/article/details/100777748
一.div 自适应设定最大高度
1.页面
<template>
    <div class="session_log_ul" ref="sessionLogUl">
       <div class="message">
        </div>    
    </div>
</template>

2.script
mounted() {
    let tableHeight = window.innerHeight - this.$refs.sessionLogUl.offsetHeight - 50;
    $(".session_log_ul .message").css({"max-height": tableHeight + 'px', 'overflow': 'auto'});
},

二.el-table 自适应设定最大高度

1.页面

<template>
    <div class="unknown">
        <div class="el-table-div">
            <el-table ref="unknownTable">

            </el-table>
        </div>
    </div>
</template>

2.script

mounted() {
    let tableHeight = window.innerHeight - this.$refs.unknownTable.$el.offsetTop - 194;
    $(".unknown .el-table-div").css({"max-height": tableHeight + 'px', 'overflow': 'auto'});
},

猜你喜欢

转载自blog.csdn.net/lhh143400/article/details/100777748