因项目需求:用户个人详细信息页面设置背景色,之前在这个页面设置最外层div发现不行。因为app.vue影响了它。后来直接在页面上用body设置样式,发现影响了其他页面。

后来想了通过vue的生命周期来解决。这个页面创建前设置我的样式,销毁之前移除我设置的样式。

代码如下:

//创建前设置
beforeCreate () {
      document.querySelector('body').setAttribute('style', 'background-color:#efeff4;')
},
//销毁前清除
beforeDestroy () {
      document.querySelector('body').removeAttribute('style')
},

 

相关文章:

  • 2021-09-27
  • 2021-10-31
  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2022-01-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
相关资源
相似解决方案