<template>
  <div style="margin:50px">
    <p class="styleA">小</p>
    <h2 class="styleB">大</h2>
  </div>
</template>
<style  lang="scss">
.styleA {
  color: palegreen;
  height: 50px;
  width: 50px;
  background-color: palevioletred;
  font-size: 30px;
}
.styleB {
  @extend .styleA;
}
</style>

  使用scss的extend 更好的继承样式 简化代码

 

如果styleB还想加其他的样式,直接在styleB样式下边加即可

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2022-12-23
  • 2022-01-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案