angular - index.html 没有加载本地 CSS

标签 angular angular-cli

我最近开始使用 AngularCLI。我已将所有文件从 Angular2 转移到 AngularCLI 项目。

但是它没有加载一些本地 css 文件,而是正在加载其他 css 文件?

当前目录是:

-src
--index
--styles.css
--app
---angular2-fullcalendar
----fullcalendar.min.css

index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Cudyangularcli</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link rel="stylesheet" type="text/css" href="styles.css">
  <link rel="stylesheet" type="text/css" href="../src/app/angular2-fullcalendar/fullcalendar.min.css" >
</head>
<body>
  <app-root>Loading...</app-root>
</body>
</html>

错误是: enter image description here

最佳答案

它没有加载,因为您需要使用 angular-cli.json 文件将 css 文件添加到项目中,而不是 index.html。为此,只需打开 angular-cli-json 并将 css 文件添加到 styles 中:

"styles": [
        "styles.css",
        "another-styles.css"
]

关于angular - index.html 没有加载本地 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44129492/

相关文章:

angular-cli - 使用 ng build 在 Angular 库中构建外部 JS(不是 TS)文件?

angular - 在 app.module.ts 文件中确定未使用的 Angular 模块

Angular 无法启动

angular - Ionic 4 中的动态进度条?

Angular Material 5 - 在 Mat 列表中显示全文(Word Wrap)

angular - 如何调用不同组件中的方法

angular - 使用 Angular cli 进行服务器端渲染

angular - 错误错误 : InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe'

javascript - 类型 Casting json to class angular 2

angular - 如何创建可配置服务 Angular 4