我刚刚使用 angulari cli 创建了一个新元素。
当我尝试在 index.html 中包含 styles.css 文件时
<link rel="stylesheet" type="text/css" href="styles.css">
我在 Chrome 的开发工具网络选项卡中收到了这个:
Refused to apply style from 'http://localhost:4200/styles.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
知道如何解决这个问题吗?我在本地使用 ng serve
我也尝试添加
./styles.css
/styles.css
styles.css
最佳答案
当我们创建 angular-cli 元素时,styles.css 将应用默认值,您可以在 .angular-cli.json 中看到它
app: {
styles:[
"styles.css"
]
如果您需要,您可以在此处根据您的元素添加更多样式。
关于css - 无法在 Angular cli 新元素中加载样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48817278/