[英]After adding react-router-dom my github pages showing nothing
添加 react-router-dom 后,我將其推送到 GitHub https://github.com/iamtheasad/user
。 In the project url my homepage are showing https://iamtheasad.github.io/user/
, after that I click to another menu item it's redirecting to another page but while I refresh another page it's showing 404 page, click on home it took我到這個鏈接https://iamtheasad.github.io/
它向我展示了空白的白頁。
我的導航組件鏈接: https://github.com/iamtheasad/user/tree/master/src/components/TopNavigation
我的路由器組件鏈接: https://github.com/iamtheasad/user/tree/master/src/router
我正在嘗試添加這些: <NavLink exact activeStyle={{color: '#00a8ee'}} className={this.state.navBarItem} to={process.env.PUBLIC_URL + '/'}>Home</NavLink> </Nav.Link>
和
<Route exact path={process.env.PUBLIC_URL + '/'} component={HomePage}/>
<Route exact path="/service" component={ServicePage}/>
<Route exact path="/course" component={CoursesPage}/>
<Route exact path="/portfolio" component={PortfolioPage}/>
<Route exact path="/contact" component={ContactPage}/>
<Route exact path="/about" component={AboutPage}/>
嘗試在房間級別的package.json
文件中添加homepage
屬性。
package.json
{
"homepage": "https://iamtheasad.github.io/user"
}
user
是存儲庫的名稱
react-router 是客戶端路由器。 要解決此問題,您需要修復服務器基礎路由器。 When user go to URL like www.user.github.io/repo github will try to serve the repo/index.html
in the github page repository to the user. 如果該文件不存在,那么它們將返回 404.html 頁面,並且它們還為您提供了一種自定義 404 頁面的方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.