【发布时间】:2022-01-31 15:17:16
【问题描述】:
-
我有两种类型的组件,i) 登录前 ii) 登录后
-
想为两个父组件添加 2 个不同的 css,
-
使用 ViewEncapsulation.None 也适用于兄弟组件,这里是代码结构
- ParentComponent1 - ChildCompoent1.1 - ChildCompoent1.2 - ParentComponent2 - ChildCompoent2.1 - ChildCompoent2.2 -
如果我在 ParentComponent1 中添加 CSS,那么它只适用于 ChildComponent1.1 和 ChildComponent1.2 而不是 2.1 和 2.2,同样适用于 ParentComponent2
有没有办法删除 ViewEncapsulation.None 或仅在子组件中应用 CSS 而不是在兄弟组件中
【问题讨论】:
-
你可以使用
ViewEncapsulation.Emulated。 -
@JigneshPanchal 如果我使用 ViewEncapsulation.Emulated 那么父组件 CSS 不适用于子组件
标签: css angular angular11 scss-lint angular2viewencapsulation