例子 -> 在父组件中
<div class="if-this-class-is-applied">
<child></child>
</div>
::ng-deep .if-this-class-is-applied > child {
// Your styles
}
<div>
<child [ngClass]="{ 'your-class-name': condition }"></child>
</div>
.your-class-name {
::ng-deep {
.child-component-class-you-want-to-alter {
max-width: 340px;
}
}
}