![](/img/trans.png)
[英]Why does my GitHub page only show the homepage for my react app and not the other pages?
[英]GH Pages shows my homepage, but not any of my other paths
最佳做法是使用相對路徑:
<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.