部署React项目后的空白页

问题描述 投票:0回答:1

首先在package.json中加入以下内容。

"homepage": "."

`"predeploy": "npm run build",

"deploy": "gh-pages -d build"`

"scripts" 部分。

那就。"start_url": "." 的清单文件中。

下一个。

npm install gh-pages --save-dev

然后我把代码推送到我的 Github 在部署到使用 npm run deploy

在Github版本库中,选择了 "gh页面分支"。

但是,只有一个空白页。我怀疑主页不正确,因为是 index.html 是在"...\react-todo-list\srcindex.js。".

reactjs github npm web-deployment
1个回答
0
投票

我按照这个非常描述性的 教程

1)原来我需要改变 "homepage": ".""homepage": "https://dmorrisonasc.github.io/ReactJS-TodoList/".

2)并更改我的路由组件导入() BrowserRouter as RouterHashRouter as Router)中的index.js文件。

3) 重新部署

© www.soinside.com 2019 - 2024. All rights reserved.