部署到github页面后的空白页面

时间:2020-11-01 12:59:09

标签: github-pages

以下是我部署到github页面的步骤:

  1. 将gh-pages软件包安装为应用程序的“开发依赖项”

    npm install gh-pages --save-dev

  2. 添加首页属性“首页”:

    “ http:// {username} .github.io / {repo-name}”

  3. 部署脚本

    “脚本”:{ // ... “ predeploy”:“ npm run build”, “ deploy”:“ gh-pages -d build” }

    npm run deploy

  4. 将源设置为gh-pages分支。 enter image description here

我转到链接,找到带有空白控制台的空白页。我环顾四周,每个人都建议执行这四个步骤,但似乎没有任何效果。 我使用npx create-react-app设置我的React应用程序。 这是我的存储库的链接:https://github.com/yuivae/yuivae

如果您有任何建议,请告诉我

1 个答案:

答案 0 :(得分:0)

2分钟,我发布了该主题,我找到了答案。我需要从以下更改react-router-dom路径设置 <Route exact path="/" component={Home} />

<Route exact path="/{app-name}" component={Home} />

因为默认情况下部署到gh页时,我将/主页路径更改为http://{username}.github.io/{repo-name} 进行此更改后,我再次推送,提交和部署,并在10秒钟后成功了。