![](/img/trans.png)
[英]Link from react-router-dom is not working properly with material-ui
[英]React-router-dom with Material-ui working but not mounting components
我正在研究這個項目: https : //codesandbox.io/s/trusting-frog-089l2我的目標是(因為 react-router-dom 應該工作)使用 Material-UI 按鈕在各種組件之間導航最佳。 唯一的問題是,當路由器工作時(我可以看到地址欄上的掛載點發生了變化),正確的組件沒有被掛載。 有誰知道如何解決這個問題?
path='/studio/'
應該替換為
path='/studio'
並且你應該改變第一條路線以獲得exact
道具並將其從其余的Route
組件中刪除
這就是您的開關的外觀:
<Switch>
<Route exact path="/" component={Home} />
<Route path="/studio" component={Studio} />
<Route path="/stanzino" component={Stanzino} />
<Route path="/affitti" component={Affitti} />
<Redirect to="/" />
</Switch>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.