class 属性在 Angular 2 中对于自定义组件有用吗? 例如:
<app-my-first-component class='darkBackground'></app-my-first-component>
看起来该类不会影响组件。
最佳答案
您可以通过向 app-my-first-component
添加样式来解决该类的问题,例如
@Component({
...,
styles: [`
:host(.darkBackground) {
color: white;
background-color: darkgrey;
}`]
})
关于javascript - Angular 2,自定义组件的类属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42633779/