在需要修改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')

Logo

前往低代码交流专区

更多推荐