尝试升级到 Angular 6,当我在 index.html 中引用以下内容时,出现以下错误:
拒绝应用来自 ' 的样式https://localhost:44394/~/assets/primengcss/themes/omega//theme.css https://localhost:44394/~/assets/primengcss/themes/omega//theme.css' 因为它的 MIME 类型('text/html')不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查。
经过一番挖掘后找到了答案(至少对我有用):
看起来在 Angular 6 中我们需要将任何外部 CSS(如 bootstrap、font Awesome、Primeneng 等)包含到 angular.json 中,如下所示:
"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"./node_modules/font-awesome/css/font-awesome.min.css",
"src/styles.css",
"./node_modules/primeng/resources/themes/omega/theme.css",
"./node_modules/primeng/resources/primeng.min.css",
"./node_modules/primeicons/primeicons.css"
],
"scripts": [
"./node_modules/jquery/dist/jquery.slim.min.js",
"./node_modules/popper.js/dist/umd/popper.min.js",
"./node_modules/bootstrap/dist/js/bootstrap.min.js"
]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)