尝试了很多修复,但在尝试部署 React Web App 时仍然出现空白 Github 页面

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

我一直在尝试将我的 React Web 应用程序提升到 gh 页面上一段时间,但它不会中断并且加载为空白。链接在这里:https://00eemsy.github.io/my-cv-website/

我已经按照其他 Stack Overflow 帖子上的建议尝试了很多方法,但没有一个有效:

  • 我将
    package.json
    "private": true
    更改为
    "private": false
  • 我已经三重检查了我的
    homepage
    URL (
    "homepage": "https://00eemsy.github.io/my-cv-website"
    )
  • 我已将
    BrowserRouter
    实施到我的
    index.js
    文件中
const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(
  <BrowserRouter basename={process.env.PUBLIC_URL}>
    {/* <App/> */}

    <nav>
      <Link to='/'></Link>
    </nav>

    <Routes>
      <Route exact path='/' element={<App />}/>
    </Routes>
  </BrowserRouter>
);

localhost
npm run build
gh-pages -d build
上一切看起来都很好,但我仍然在任何其他设备或除 Chrome(我最常用的浏览器)之外的任何其他网络浏览器上看到空白网页。很确定没有错误的链接,但似乎它只在 Chrome 上显示正常,而在其他地方却显示不出来。

reactjs git github-pages
1个回答
0
投票

这个方法对我有用:https://dev.to/rashidshamloo/deploying-vite-react-app-to-github-pages-35hf

不要忘记将发布源设置为Github中的

gh-pages
分支
Settings > Pages > Build and Deployment

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