美文网首页
登录页获取当前浏览器宽高铺满

登录页获取当前浏览器宽高铺满

作者: fanyu__ | 来源:发表于2021-05-05 15:09 被阅读0次
    <template>
        <div class="login" :style="`width:${width}px;height:${height}px`">
        </div>
    </template>
    
    <script lang="ts">
    import { Vue, Component } from 'vue-property-decorator'
    
    @Component({ components: {} })
    export default class Login extends Vue {
        get width() {
            return this.$store.state.width
        }
    
        get height() {
            return this.$store.state.height
        }
    
        mounted() {
            this.$store.commit('setWidth', window.innerWidth)
            this.$store.commit('setHeight', window.innerHeight)
            window.onresize = () => {
                return (() => {
                    this.$store.commit('setWidth', window.innerWidth)
                    this.$store.commit('setHeight', window.innerHeight)
                })()
            }
        }
    }
    </script>
    
    <style lang="scss">
    .login {
        background: url('../assets/login.jpg');
        background-size: 100% 100%;
    }
    </style>
    
    

    相关文章

      网友评论

          本文标题:登录页获取当前浏览器宽高铺满

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