【问题标题】:Styles was not loaded because its MIME type in React application样式未加载,因为它在 React 应用程序中的 MIME 类型
【发布时间】:2021-05-17 08:48:26
【问题描述】:

我有使用 Craco 作为 create-react-app 配置层的 React 应用程序

遇到样式在生产中没有随机加载的问题。

错误The stylesheet some.chunk.css was not loaded because its MIME type, "text/html", is not "text/css" in

这个问题已经有很多帖子了,搜索大部分 像这样的解决方案对我没有帮助:

  • 添加<base href="/">
  • 在 package.json 中添加 "homepage": "/"
  • link 标签添加type="css",样式是自动生成的,所以这不起作用

你们有什么想法吗?

【问题讨论】:

    标签: javascript css reactjs build react-scripts


    【解决方案1】:

    在我的项目中,我通过将 css 文件的链接标记中的 href="" 替换为 rel="" 来解决它。

    【讨论】:

      猜你喜欢
      • 2016-12-23
      • 2018-04-19
      • 2019-11-20
      • 2019-05-02
      • 2019-08-24
      • 2020-06-22
      • 2018-11-25
      • 2018-07-08
      • 2011-01-12
      相关资源
      最近更新 更多