sass 和 less 的样式穿透

929 阅读1分钟

这两个常用的样式穿透的方式 有两种 分别是 /deep/ 与 ::v-deep

外层容器 /deep/ 组件 { }
外层容器 ::v-deep 组件 { }
.Userdescriptions /deep/ .ant-descriptions-item-content {
  border-color: #fff !important;
}
.userstatus ::v-deep {
  button {
    height: 25px;
  }
  .ant-switch::after {
    height: 21px;
    width: 21px;
  }
}

注意1:不一定要加上外层容器,看情况而定

注意2:在vue中一定要加上scoped,否则不会生效

举例:

<style lang="scss" scoped>
.el-submenu /deep/ .el-submenu__title:hover { 
    color: rgba(255, 134, 50, 1) !important; 
    background-color: #fff !important;
}
</style>