【问题标题】:Load CSS Module Wise in Angular在 Angular 中明智地加载 CSS 模块
【发布时间】:2020-02-20 11:45:53
【问题描述】:

这是场景 -

我的 Angular 应用程序中有多个模块。前 -

app.module.ts
    student.module.ts
        component A
        component B
        component C
    admin.module.ts
        component A
        component B
        component C
    .
    .
    .

根据上述层次结构,我有两个新模块(学生和管理员),每个模块都有单独的组件。

现在我想明智地加载 CSS 文件模块,以便它可以应用于该模块的所有组件,而不是该模块之外。

如果我在 style.css 中调用 CSS 文件,那么它将在全局范围内应用,这是我不想要的。

那么有什么办法可以做到这一点,因为我不想在每个组件的 css 文件中编写 CSS,因为它对于特定模块的组件很常见。

【问题讨论】:

标签: css angular


【解决方案1】:

如果它有效,我现在不知道,但你试试这个:

把它放在你的组件中:

 import 'path/folder/module.css';

将 .css 路径放在这个导入中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-01
    • 2019-02-23
    • 1970-01-01
    • 2015-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多