【发布时间】:2018-11-12 23:15:22
【问题描述】:
我正在尝试在我的 Angular 6 应用程序中添加基本的重置样式。 但我在控制台中不断收到以下错误。
**
拒绝应用样式来自 'http://localhost:4200/app/style-components/reset.css' 因为它 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型,并且 已启用严格的 MIME 检查。
**
如您所见,我的 css 文件名为 reset.css,我在 index.html 中使用以下行来添加此文件。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>EasyNotes</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="app/style-components/reset.css">**
</head>
<body>
<app-root></app-root>
</body>
</html>
我是这个新版本的 Angular 的新手,它对我来说是一个障碍。 在此先感谢:)
【问题讨论】:
-
你去localhost:4200/app/style-components/reset.css时看到你的样式表了吗?
-
尝试导航到localhost:4200/app/style-components/reset.css 并查看其中包含的内容。可能服务器没有提供正确的文件
-
这是很好的answer 类似问题。