我正在开发Angular 4应用,我想应用一些全局样式。在有关角度站点的教程之后,我在应用程序的根目录中创建了一个“
styles.css”文件,并在我的应用程序的index.html中引用了该样式表:
angular应用已成功编译:
$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200 **
[...]
webpack: Compiled successfully.
但是,当我在Chromium浏览器中访问http://
localhost:4200时,控制台显示错误消息
GET http://localhost:4200/styles.css
在Firefox浏览器中,该错误更为明显:
GET
http://localhost:4200/styles.css [HTTP/1.1 404 Not Found 15ms]
The resource from "http://localhost:4200/styles.css" was blocked due to MIME type mismatch (X-Content-Type-Options: nosniff).
这两个文件index.html和styles.css都位于我的角度应用程序的根目录中。我试图获得有关该问题的更多信息:
nosniff
Blocks a request if the requested type is
"style" and the MIME type is not "text/css", or
"script" and the MIME type is not a JavaScript MIME type.
但是我不明白为什么它使请求无效,因为我type="text/css"在引用样式表时已指定。