试图升级到Angular 6,当我在index.html中引用以下内容时,出现了以下错误:
拒绝应用"的样式https://localhost:44394/~/assets/primengcss/themes/omega//theme.css',因为其MIME类型('text/html/(不是支持的样式表MIME类型,并且启用了严格的MIME检查。
经过一番挖掘,找到了答案(至少对我有效(:
看起来在angular 6中,我们需要在angular.json中包含任何外部CSS(如bootstrap、font真棒、Priming等(,如下所示:
"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"
]