A2 Hosting服务器上的内容未呈现

The content on the A2 Hosting server is not rendered

提问人:Ilya 提问时间:11/1/2023 最后编辑:gre_gorIlya 更新时间:11/1/2023 访问量:24

问:

谁使用过 A2 Hosting 服务,告诉我,我将我的 React 项目的文件上传到public_html,由于某种原因,我的网站上应该呈现的内容没有呈现。这是我的文件:

索引.js:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App'; 

import './index.css';

window.onload = () => {
  ReactDOM.createRoot(document.getElementById('root')).render(
    <React.StrictMode>
      <App />
    </React.StrictMode>
  );
};

manifest.json:

{
  "short_name": "React App",
  "name": "Create React App Sample",
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "64x64 32x32 24x24 16x16",
      "type": "image/x-icon"
    },
    {
      "src": "logo192.png",
      "type": "image/png",
      "sizes": "192x192"
    },
    {
      "src": "logo512.png",
      "type": "image/png",
      "sizes": "512x512"
    }
  ],
  "start_url": "https://famfindtree.com/",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}

package.json:

{
  "name": "genealogy-commercial-project",
  "version": "0.1.0",
  "private": true,
  "homepage": "https://famfindtree.com",
  "dependencies": {
    "@mui/icons-material": "^5.14.7",
    "@mui/material": "^5.14.7",
    "@testing-library/jest-dom": "^5.16.3",
    "@testing-library/react": "^12.1.4",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^1.5.0",
    "bingmaps": "^2.0.3",
    "bingmaps-react": "^1.2.10",
    "express": "^4.18.2",
    "react": "^18.1.0",
    "react-dom": "^18.1.0",
    "react-router-dom": "^6.15.0",
    "react-scripts": "^5.0.1",
    "sass": "^1.66.1",
    "web-vitals": "^2.1.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "lint:js": "eslint src/**/*.{js,jsx}"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

索引.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="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"
    />
    <link rel="manifest" href="manifest.json" />
    <link rel="shortcut icon" href="favicon.ico" />
    <title>FamFindTree</title>
    <script type="text/javascript">
      (function (l) {
        if (l.search[1] === '/') {
          var decoded = l.search
            .slice(1)
            .split('&')
            .map(function (s) {
              return s.replace(/~and~/g, '&');
            })
            .join('?');
          window.history.replaceState(
            null,
            null,
            l.pathname.slice(0, -1) + decoded + l.hash
          );
        }
      })(window.location);
    </script>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
  </body>
</html>

我认为可能路径或类似的东西有问题,因为控制台中没有错误,而且通常一切正常,但反应的这一部分不起作用。

javascript html reactjs json

评论

0赞 gre_gor 11/2/2023
您甚至没有包含任何 .js 文件。浏览器无论如何都无法读取您的 .js(实际上是 jsx)文件。请阅读部署

答: 暂无答案