我正在开发一个Angular 4应用程序,我想应用一些全局样式.在
tutorial at the angular site之后,我在我的应用程序的根目录中创建了一个“styles.css”文件,我指的是我的应用程序的index.html中的样式表:
角度应用程序已成功编译:
$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都位于我的角度应用程序的根目录中.
我试图得到more info about the problem:
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”.