簡體   English   中英

GH Pages 顯示我的主頁,但沒有顯示我的任何其他路徑

[英]GH Pages shows my homepage, but not any of my other paths

回購鏈接)(實時鏈接

幾天來一直在為 gh-pages 苦苦掙扎並做出反應,現在將我的投資組合從 url 中展示出來; 在本地主機上工作得很好。 我已經到了第一頁可以正常顯示的地步,但是一旦您 select 導航欄的另一個路徑,它會返回 404 錯誤“加載資源失敗”。 我嘗試用一堆不同的方式弄亂基本名稱路由,但沒有成功。 任何見解將不勝感激!

最佳做法是使用相對路徑:

<a class="MuiButtonBase-root ..." tabindex="0" aria-disabled="false" href="projects">
  ^^^^^^^^

而不是/iacoviello-portfolio-react/projects

假設您的路由器確實管理這些路徑,如本例所示

export default function BasicExample() {
  return (
    <Router>
      <div>
        <ul>
          <li>
            <Link to="/">Home</Link>
          </li>
          <li>
            <Link to="about">About</Link>
          </li>
          <li>
            <Link to="dashboard">Dashboard</Link>
          </li>
        </ul>

        <hr />

        {/*
          A <Switch> looks through all its children <Route>
          elements and renders the first one whose path
          matches the current URL. Use a <Switch> any time
          you have multiple routes, but you want only one
          of them to render at a time
        */}
        <Switch>
          <Route exact path="/">
            <Home />
          </Route>
          <Route path="/about">
            <About />
          </Route>
          <Route path="/dashboard">
            <Dashboard />
          </Route>
        </Switch>
      </div>
    </Router>
  );
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM