<template>
    <div class="layout" id="layout" ref="layout" :style="`width:${width}px;height:${height}px`">
    </div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
@Component({
    components: {}
})
export default class Layout extends Vue {
    height = 0
    width = 0
    mounted() {
        this.$nextTick(() => {
            this.width = window.innerWidth
            this.height = window.innerHeight
        })
        window.onresize = () => {
            return (() => {
                this.width = window.innerWidth
                this.height = window.innerHeight
            })()
        }
    }
}
</script>
<style lang="scss" scoped>
.layout {
    background: darkcyan;
}
</style>
获取当前浏览器大小并设置布局
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
 平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 网页可见区域宽:document.body.clientWidth网页可见区域高:document.body.cl...
- 网页可见区域宽:document.body.clientWidth 网页可见区域高:document.body.c...
- // 获取窗口宽度 if (window.innerWidth)winWidth = window.innerWi...