我的 Ionic在我想在我的 iPhone 上进行测试之前,build 一直运行良好,所以我停止了我的服务器,做了一个 ionic serve --address localhost
,我注意到我的样式表不再加载了......所以我再次杀死服务器回到 ionic serve
并且错误仍然存在......
(index):1 Refused to apply style from 'http://localhost:8100/build/main.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
我已经尝试清除 localhost:8100
上的缓存并重建项目,但错误仍然存在...
我该如何解决这个问题?
我最终修复它的方式可能不是最好的……但至少它再次起作用了。我刚刚进入我的 GitHub 存储库,我的应用程序下载了 main.css
并将其粘贴到 build
文件夹中,此后我没有遇到任何问题。
最佳答案
我遵循了 ionic 框架论坛上发布的这些说明。
Serve your project with
ionic serve
and then just change any .ts file and save it (ctrl+s
) and it will automatically build again and serve the app & error will be resolved, hopefully :).
注意:您必须在每次初始 ionic 发球时执行此操作。
查看完整答案 here
关于javascript - Ionic 和 Angular 2 - 拒绝应用来自 'http://localhost:8100/build/main.css' 的样式,因为它的 MIME 类型 ('text/html' 不受支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48977389/