上传到github页面的React网站显示空白背景,没有内容

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

所以,我正在尝试使用 github 页面上传这个 React 构建的网站:https://github.com/mihalistsop/myportfolio

当我按照所有步骤操作并发布网站时,我仅获得在 localhost:8000 中运行 npm start 时预览的背景。看起来上传的网站是 localhost:8000/a_blank_page 如果有意义的话,而不是内容所在的 localhost:8000。

编辑:我把路由器弄乱了一点,现在我只发布了一个空白的白页:)

如果有人可以帮助我解决这个问题,我将非常感激。提前谢谢你们了!如果我需要分享其他内容,请随时告诉我。

reactjs github github-pages
1个回答
0
投票
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
import React from "react";
import RoundOne from "./components/roundDesigns/RoundOne";
import RoundTwo from "./components/roundDesigns/RoundTwo";
import RoundThree from "./components/roundDesigns/RoundThree";
import RoundFour from "./components/roundDesigns/RoundFour";
import RoundFive from "./components/roundDesigns/RoundFive";
import Home from "./Home";

function App() {
  return (
    <Router>
      <div className="w-full lgl:h-screen font-bodyfont overflow-hidden text-textColor bg-black relative">
        <div className="max-w-screen-2xl h-full mx-auto flex justify-center items-center">
        <Routes>
          <Route path="/" element={<Home />} />
            </Routes>
        </div>
        <div className="w-full h-full absolute top-0 left-0 z-10">
          <RoundOne />
          <RoundTwo />
          <RoundThree />
          <RoundFour />
          <RoundFive />
        </div>
      </div>
    </Router>
  );
}

export default App;

您必须将 Home 元素路径从“/”更改为“/mihalistsop/myportfolio”,然后重建并部署您的应用程序它将起作用。

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