javascript - Ionic 和 Angular 2 - 拒绝应用来自 'http://localhost:8100/build/main.css' 的样式,因为它的 MIME 类型 ('text/html' 不受支持

标签 javascript angular ionic-framework ionic2

我的 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/

相关文章:

javascript - 即使光标 : none;,当您悬停时光标也会闪烁

javascript - 使用 is() 和多个 CSS 类进行 JQuery 验证

Angular2 viewContainerRef.createComponent 正常工作

css - 在 angular6 组件中使用动态 css

angularjs - Moment.js 未捕获的语法错误

javascript - 使用操作在 coffeescript 中循环

javascript - 饼图内有文字的圆环图也向下

javascript - ionic /Angular ng-click 选择输入

css - 为什么子组件样式会被全局 css 覆盖?

android - Ionic 有没有办法直接在 Android 或 iOS 设备上进行调试?