想要在一个页面级的组件内修改body的背景色或者背景图,

想要在一个页面级的组件内修改body的背景色或者背景图,但是直接在组件内部写样式会影响其他页面组件;
此时只需要在该组件内如此设置:

 beforeCreate() {
       document.querySelector('body').setAttribute('style', 'background:#eee')
  }, //
   beforeDestroy() {
    document.querySelector('body').removeAttribute('style')
  }, /
  同时在再style标签上加scoped即可;

  

原文地址:https://www.cnblogs.com/sinceForever/p/14100957.html