首页 > 解决方案 > 在 gh-pages 上部署 react 项目,但页面没有更新

问题描述

我正在尝试在我的 GitHub 页面(gh-pages 分支)上部署我的反应项目。但是我的 GitHub 页面没有更新。

这是我的package.json

...,
"homepage': "https://marukohua.github.io/portfolio/",
"dependencies": {
  ... 
},
"scripts": { 
  "deploy": "npm run build&&gh-pages -d build"
},
...

我认为这在我的路由器路径中是可能的。所以我process.env.PUBLIC_URL在我的路由路径中使用。但是我的页面和以前一样。

这是我的路线路径:

<BrowserRouter>
  <Switch>
    <Route
      path={`${process.env.PUBLIC_URL}/`}
      exact
      component={ProjectsPage}
    />
    <Route 
      path={`${process.env.PUBLIC_URL}/about`} 
      component={AboutPage} />
    <Route
      path={`${process.env.PUBLIC_URL}/projects`}
      component={ProjectsPage}
    />
  </Switch>
</BrowserRouter>

标签: reactjsgithubreact-routergithub-pages

解决方案


推荐阅读