ceshi

143 阅读1分钟
  • 对用页面级组件样式,应该是有作用域的
  • 对于公用组件或者全局组件库,我们应该更倾向于选用基于 class 的 BEM 策略
  <style lang='scss'></style> // bad

  <!-- 使用 scoped 作用域 -->
  <style lang='scss' scoped></style> // good

  <!-- 使用 BEM 约定 -->
  <style> // good
  .c-Button {
    border: none;
    border-radius: 2px;
  }

  .c-Button--close {
    background-color: red;
  }
  </style>