vue中怎么修改单个页面body的背景色
在需要修改body背景色的.vue文件里,写如下js代码beforeCreate() {document.querySelector('body').setAttribute('style', 'background-color:#fff')},beforeDestroy() {document.querySelector('body').removeAttribute('style')},设置完
·
在需要修改body背景色的.vue文件里,写如下js代码
beforeCreate() {
document.querySelector('body').setAttribute('style', 'background-color:#fff')
},
beforeDestroy() {
document.querySelector('body').removeAttribute('style')
},
设置完后 , 这个页面的背景色就会变成白色 , 别的页面不会影响 , 但会影响到字体大小 , 某个页面的一些字会变大 , 这时候单独给变大的字设置font-size就可以了
改多个样式
document.querySelector('.nav').setAttribute('style', 'background-color:#177eff;color:#fff')
更多推荐
已为社区贡献9条内容
所有评论(0)