Angular 6-拒绝应用'...'中的样式,因为它的MIME类型('text/html')不支持 [英] Angular 6 - Refused to apply style from '...' because its MIME type ('text/html') is not a supported stylesheet

查看:397
本文介绍了Angular 6-拒绝应用'...'中的样式,因为它的MIME类型('text/html')不支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试升级到Angular 6并在index.html中引用以下内容时出现以下错误:

Trying to upgrade to Angular 6 and got the below error when I referred the below in index.html:

拒绝应用来自' https://localhost的样式: 44394/〜/assets/primengcss/themes/omega//theme.css ",因为它的MIME类型('text/html')不是受支持的样式表MIME类型,并且启用了严格的MIME检查.

Refused to apply style from 'https://localhost:44394/~/assets/primengcss/themes/omega//theme.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

推荐答案

经过一番摸索,找到了答案(至少对我有用)

Found the answer (at least worked for me), after some digging around:

像inAngular 6一样,我们需要将所有外部CSS(例如bootstrap,fontawesome,Primeng等)包括到angular.json中,如下所示:

Looks like inAngular 6 we need to include any external CSS (like bootstrap, fontawesome, Primeng etc.,) to the angular.json as below:

        "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"
        ]   

这篇关于Angular 6-拒绝应用'...'中的样式,因为它的MIME类型('text/html')不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆