vue中给body单独设置样式
在vue项目中,有时候会需要给单独的页面中的body设置样式,下面是两种方法1.在beforeCreate()中给body添加属性beforeCreate() {document.querySelector('body').setAttribute('style', 'background-color:#fffcf5;')},2.给最外层的div添加个类名,然后处理<template>
·
在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>
目前就知道这两种,以后看到了再补充吧
更多推荐
已为社区贡献5条内容
所有评论(0)