繁体   English   中英

为什么我的反应 web 应用程序返回白色/空白页面?

[英]Why is my react web app returning a white/blank page?

我一直在尝试托管使用 create-react-app 创建的 react web 应用程序。 我正在使用 Hostinger。 我得到的只是这个白色/空白页。

在我的本地服务器上它工作正常,在 github 页面上它工作正常。 目前,我将 package.json 中的“主页”设置为正确的域。 我还尝试将其设置为“。” 正如一些人对其他类似问题的建议。

起初我在控制台上遇到 2 个错误:

  1. 样式表未加载,因为它的 MIME 类型“text/html”不是“text/css”。
  2. SyntaxError:预期的表达式,得到“<”。

经过大量调整和重建后,我仍然得到白色/空白页面,但现在控制台为我提供了多个文件的 404 状态。 他们是:

  • 静态/css/main.0d200d10.chunk.css
  • 静态/js/2.f331c7cc.chunk.js
  • 静态/js/main.0e5eb86e.chunk.js

它现在还为 2 个单独的文件提供 1 个警告:

  • 源为“<url>/static/js/2.f331c7cc.chunk.js”的 <script> 加载失败。” 和来源“<url>/static/js/main.0e5eb86e.chunk.js”。

这就是 index.html 的样子

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="Web site created using create-react-app"
    />
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>Cachorro Sensível Filmes</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
  </body>
</html>

该网站是https://cachorrossensivel.com.br

任何想法都非常受欢迎。

编辑:我回到重新上传 .htaccess 后提到的 2 个原始错误。 如果我在脚本标签中指定“type=text/jsx”并从链接标签中删除“rel=stylesheet”,我不会收到任何错误,但它仍然是空白的。

我正在 Chrome 和 Firefox 上进行测试,并且我已经清除了缓存。

我搞砸了上传到文件管理器。 它进入 public_html -> 文件/静态文件夹 -> static 中的文件夹 -> 文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM