首页 文章

Github页面上的Create-React-App返回一个空白页面

提问于
浏览
3

在本地测试时,我的create-react-quiz应用程序完美运行 . 我的项目基于这段代码:https://github.com/mitchgavan/react-multi-choice-quiz/tree/gh-pages .

但是,当我在"GitHub-Pages"分支上使用npm build deploy时,会出现一个空白页面,并且这些错误会显示在控制台中: pk8189.github.io/:1 GET pk8189.github.io/pk8189/futureU-/static/css/main.1dc4d41f.css pk8189.github.io/:1 GET pk8189.github.io/pk8189/futureU-/static/js/main.28e294a0.js

这是我的回购:https://github.com/pk8189/futureU-您认为这个问题是什么?感谢您的任何帮助 .

1 回答

  • 7

    创建React应用程序使用 package.json 中的 homepage 字段来确定应用程序所在的URL . 由于您set it to https://github.com/pk8189/futureU-/,它会尝试从 /pk8189/futureU-/ 请求不存在的资产 .

    更改 homepage 以匹配您部署的网址: https://pk8189.github.io/futureU-/ . 然后通过运行 npm run build 重建并重新部署 .

    这在deployment instructions for GitHub Pages中有描述 . 请阅读用户指南的这一部分 .

相关问题