美文网首页
让vue的view页面同时设置局部和全局style样式

让vue的view页面同时设置局部和全局style样式

作者: JX灬君 | 来源:发表于2021-06-29 10:13 被阅读0次
    在同一个vue文件里里同时加入style即可跟普通html页面差不多,可以写多个style。想要设置局部样式就加scoped,设置全局样式就不加scoped
    <style lang="scss">
    html,
    body,
    #app {
      height: 100%;
    }
    </style>
    <style lang="scss" scoped>
    h1 {
      text-align: center;
      font-size: px2rem(36);
      height: px2rem(148);
      padding: px2rem(148-36-44) 0 px2rem(44) 0;
      line-height: px2rem(36);
      color: #fff;
    }
    .login {
      background-color: #2ade69;
      height: 100%;
    }
    </style>
    

    加scoped之后vue会自动给dom加上data-v-xxxx属性用来确定局部范围。

    // 加scoped之后
    <h1 data-v-234234234>登录</h1>
    

    相关文章

      网友评论

          本文标题:让vue的view页面同时设置局部和全局style样式

          本文链接:https://www.haomeiwen.com/subject/nzuhultx.html