Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前正在做一些将 Angular 应用程序共享为 Web 组件的实验,并且我遇到了一个应用程序的样式影响另一个应用程序的问题。
鉴于我使用模拟视图封装这一事实,Angular 将为我的元素添加特殊_nghost-c#和_ngcontent-c#道具,并更新样式以使用它们。现在,由于我可能在一个页面中有多个 Angular 应用程序,这些选择器可能会影响其他应用程序。
_nghost-c#
_ngcontent-c#
我在网上看到了一些例子,其中这些道具中有一个命名空间,例如_nghost-XXX-#,但我找不到自定义它的方法。
_nghost-XXX-#
此问题的修复程序刚刚在Angular v8中发布。
它是在beta 12中引入的。
对于以前的 Angular 版本,如果不自己引入更改,是没有办法解决的。