1. 问题:
开发过程中,可能不同路由页面背景色不一样,可以通过js来设置。
2. 解决:
- 直接在当前的page内设置
mounted() {
  document.querySelector('body').setAttribute('style', 'background-color:#f7f7f7')
},
beforeDestroy() {
  document.querySelector('body').removeAttribute('style')
}
- 在全局路由钩子添加
  // 设置背景色
  if (to.meta.background === 'gray') {
    document.querySelector('body').setAttribute('style', 'background: #f7f7f7')
  } else {
    document.querySelector('body').setAttribute('style', 'background: #fffff')
  }
快来评论一下吧!
发表评论