reactjs - 在 Github.io 上看不到任何组件
问题描述
当我在github.io上创建 React 项目时,我在 Chrome 中看不到任何组件。
在“myUserName.github.io”存储库中,有一个通用的 HTML 文件。存储库中的一个目录是我的 React 项目文件夹:
和 HTML 文件:
像这些图片,<div id="root">
是空的。但是当我在 上使用它时localhost
,它确实运行。
可能是什么问题呢?
------------------- 添加源代码 -----------------------
目录 :
__ index.html (1)
|__ 反应 __ 太空旅行 __ 构建 __ 静态 __ ...
。. . . . . . . . . . . . . . . . . | . . . . . . |__ 索引.html
。. . . . . . . . . . . . . . . . . |__ 节点模块 __ ...
. . . . . . . . . . . . . . . . . . |__ 公共 __ index.html (2)
。. . . . . . . . . . . . . . . . . |__ src __ App.js
。. . . . . . . . . . . . . . . . . |。. . . . |__ index.js (3)
。. . . . . . . . . . . . . . . . . |。. . . . |__ registerServiceWorker.js
。. . . . . . . . . . . . . . . . . |__package.json
(1) 项目的 index.html :
<!DOCTYPE html>
...
<body>
<div>Index Page</div>
<a href='./react/space-trip/public/index.html'>Go</a>
<a href='./react/space-trip/build/index.html'>Go - build</a>
</body>
</html>
(2) public/index.html :
<!DOCTYPE html>
<html lang='en'>
<head>
...
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id='root'></div>
</body>
</html>
(3) index.js :
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
构建此项目后,我将 url 添加到 [build]-[index.html],它也是空的。我也试过在没有 registerServiceWorker 的情况下运行这个页面,但它是一样的。
解决方案
推荐阅读
- spring-boot - 用户的 findall () 角色存储库存在 StackOverflowError 问题。填充 data.sql
- hibernate - Hibernate:将一对多引用从非主键映射到主键
- android - 片段和活动之间沟通的最佳方式
- jquery - 如何将失败方法调用到 jquery.get/post 成功方法中?
- python - 具有条件返回值的自定义损失
- hadoop - 使用 JAAS 配置的 Kerberos java 到 impala keytab 身份验证
- python - 删除满足某些标准的子阵列的问题
- html - 使用 ngFor - Angular 实现引导表
- flutter - 如何用 Flutter 制作这个表格
- sql - 按特定条件对 sql 结果进行分组