vue在单页设置body背景色

1.直接在当前的page内设置,这种方法不太好,因为会改变全局的样式

mounted() {
    document
      .querySelector("#app")
      .setAttribute("style", "background-color:#FFFFFF");
  },
  beforeDestroy() {
    document.querySelector("#app").removeAttribute("style");
  },

2.给组件内部最外层的元素加个min-height或者想要的高度,再设置背景色

<template>
  <div class="vipcenter">
  </div>
</template>

<style lang="scss" >
.vipcenter {
  min-height: 667px;
  background: #ffffff;
}
</style>
发布了26 篇原创文章 · 获赞 6 · 访问量 5089

猜你喜欢

转载自blog.csdn.net/Blablabla_/article/details/102730552