如何在Angular中使用样式用于整个应用角4

时间:2018-03-27 20:14:09

标签: html css angular typescript

我想在样式的角色应用程序中创建一般样式,当我创建仅用于HTML的组件时,这可能吗? 我试过这样但是没有用。

@import "../../styles";

我正在接受此错误。

Here is the Photo to show the error

2 个答案:

答案 0 :(得分:1)

我改变了

@import "../../styles";

@import "../../styles.css";

这是有效的。

答案 1 :(得分:0)

检查项目根文件夹中的.angular-cli.json。它应该包含这一部分:

{
  "apps": [
    {
      "styles": [
        "styles.css",
        "my-other-global-steylesheets.css"
      ],
    }
  ]
}

或将其添加到<head>的{​​{1}}部分,例如:

index.html

在大多数情况下,不需要对每个组件的样式表进行开发导入。这可能会不必要地增加应用程序的大小。

See more in the Angular CLI wiki