使用GitHub页面,白屏空白 [英] Using GitHub pages, blank white screen

查看:533
本文介绍了使用GitHub页面,白屏空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用[username] .github.io在github页面上创建一个react项目.但是当我打开链接时,它只会返回白色屏幕,而没有任何错误消息.当我使用自定义域名时,也会发生这种情况.

I'm trying to make a react project on github pages using [username].github.io. but when I go on the link, it just returns a white screen without any error messages. This also happens when I use a custom domain name.

但是,当我在本地运行它时,以及当我使用gh-pages而不是用户存储库时,它都可以工作.

However, it works when I run it locally and also when I use gh-pages instead of a user repo.

我使用了 https ://medium.freecodecamp.org/surge-vs-github-pages-deploying-a-create-react-app-project-c0ecbf317089 将我的所有文件上传到github,因为我在之后创建了回购协议我完成了,但是我对其进行了一些微调,使其在没有gh页的情况下也可以正常工作.

I used https://medium.freecodecamp.org/surge-vs-github-pages-deploying-a-create-react-app-project-c0ecbf317089 to upload all my files into github since I created the repo at the end after I finished, but I tweaked it a little to work without gh-pages.

我还提到了以下答案:托管gh-pages在自定义域上为空白页,但对我没有任何帮助.

I also referred to this answer: hosting gh-pages on custom domain, white empty page but it didn't do anything for me.

有人知道如何解决此问题吗?谢谢!

Does anyone know how to fix this? Thanks!

推荐答案

BrowserRouter 更改为 HashRouter 如下

Change BrowserRouter to HashRouter as follow

之前:

import { BrowserRouter } from "react-router-dom"

ReactDOM.render(
    <BrowserRouter><App /></BrowserRouter>,
    document.getElementById('root')
);

之后:

import { HashRouter } from "react-router-dom"

ReactDOM.render(
    <HashRouter><App /></HashRouter>,
    document.getElementById('root')
);

这篇关于使用GitHub页面,白屏空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆