简体   繁体   English

范围CSS仅在Angular 5中模块,以防止出血到app的其他部分

[英]Scope CSS to module only in Angular 5 to prevent bleeding into other parts of app

How do I scope CSS to only a module in Angular? 如何将CSS范围仅限于Angular中的模块? When I load a module lazily, and have ViewEncapsulation.None in that module, the CSS bleeds into other parts of my app. 当我懒惰地加载模块,并在该模块中使用ViewEncapsulation.None时,CSS会渗透到我的应用程序的其他部分。 Any idea how to prevent that, or keep that CSS only for that module in Angular 5? 知道如何防止这种情况,或者只为Angular 5中的那个模块保留CSS吗?

There is no such think as module CSS scope. 没有像模块CSS范围这样的思考。

The default ViewEncapsulation.Emulated does that per component. 默认的ViewEncapsulation.Emulated为每个组件执行此操作。 With ViewEncapsulation.None you disable that. 使用ViewEncapsulation.None可以禁用它。 There are no other ways provided by Angular. Angular没有其他方法。

You can add a CSS class or attribute to every component in a module and add that class or attribute to every selector in that module to limit the CSS to components of that module. 您可以将CSS类或属性添加到模块中的每个组件,并将该类或属性添加到该模块中的每个选择器,以将CSS限制为该模块的组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM