为什么要封装:ViewEncapsulation.ShadowDom对于某些组件不起作用

时间:2020-02-28 17:47:57

标签: angular

在下面的演示代码中,encapsulation: ViewEncapsulation.ShadowDom以我不理解的方式工作。

场景:

  1. 转到AppComponent,取消注释encapsulation: ViewEncapsulation.ShadowDom。样式将传递给所有子组件。好吧,再次评论。

  2. 转到Child2Component,取消注释encapsulation: ViewEncapsulation.ShadowDom。什么都没有呈现。为什么呢我希望所有 GrandChildComponents 都继承样式(h1都为red),而Child2Component应该保持不受影响。我错了吗 ?

有了NoneEmulated,一切按预期进行。 Native似乎是deprecated as per the docs。表格删除了Native

Here is the demo code

1 个答案:

答案 0 :(得分:0)

有一个针对角度的活动错误,如果您查看控制台错误,则会从随附的演示应用程序中看到类似的错误。

https://github.com/angular/angular/issues/31135