第三方组件的样式穿透

在开发中修改第三方组件样式是很常见,但由于 scoped 属性的样式隔离,可能需要去除 scoped 或是另起一个 style 。这些做法都会带来副作用(组件样式污染、不够优雅),样式穿透在css预处理器中使用才生效。

less使用 /deep/
<style scoped lang="less">
  .content /deep/ .el-button {
      height: 60px;
  }
</style>
scss使用 ::v-deep
<style scoped lang="scss">
.content ::v-deep .el-button {
  	height: 60px;
}
</style>
stylus使用 >>>
<style scoped ang="stylus">
外层 >>> .custon-components{
      height: 60px;
  }
</style>
posted @ 2020-10-14 11:23  85号bobo  阅读(388)  评论(0)    收藏  举报