美文网首页
Vue——获取整屏高度

Vue——获取整屏高度

作者: 上海_前端_求内推 | 来源:发表于2022-03-04 16:10 被阅读0次

一、css 高度设置成100vh height: 100vh;

二、动态获取

HTML

<div class="content" :style={height:vdaH}></div>

JS

<script>
    export default {
        name: 'login',
        data() {
            return {
                vdaH:0,
            }
        },
        methods: {
            
        },
        created() {
            let h = document.documentElement.clientHeight || document.body.clientHeight;
            this.vdaH = h - 130 + 'px';
        },
    };
</script>

3,css计算属性

.page_content {
  height: calc(100vh - 200px);
}

相关文章

网友评论

      本文标题:Vue——获取整屏高度

      本文链接:https://www.haomeiwen.com/subject/rvrmrrtx.html