在vue项目中,有时候会需要给单独的页面中的body设置样式,下面是两种方法

1.在beforeCreate()中给body添加属性
  beforeCreate() {
            document.querySelector('body').setAttribute('style', 'background-color:#fffcf5;')
        },
2.给最外层的div添加个类名,然后处理
<template>
    <div class="body-bg"></div>
</template>
<style scoped lang="scss">

    .body-bg {
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        overflow-y: auto;
        background-color: #fff;
    }
</style>

目前就知道这两种,以后看到了再补充吧

Logo

前往低代码交流专区

更多推荐