简体   繁体   English

React-router-dom 与 Material-ui 工作但不安装组件

[英]React-router-dom with Material-ui working but not mounting components

I'm working on this project: https://codesandbox.io/s/trusting-frog-089l2 My goal is to (as react-router-dom is supposed to work) navigate among various components using the Material-UI buttons on top.我正在研究这个项目: https : //codesandbox.io/s/trusting-frog-089l2我的目标是(因为 react-router-dom 应该工作)使用 Material-UI 按钮在各种组件之间导航最佳。 Only problem is, while the router works (I can see the mountpoint changing on the address bar), the right component does not get mounted.唯一的问题是,当路由器工作时(我可以看到地址栏上的挂载点发生了变化),正确的组件没有被挂载。 Does anyone know how to solve this?有谁知道如何解决这个问题?

 path='/studio/'

should be replaced with应该替换为

path='/studio'

and also u should change the first route to have exact prop and remove it from the rest of the Route components并且你应该改变第一条路线以获得exact道具并将其从其余的Route组件中删除

this is how your switch should look like:这就是您的开关的外观:

<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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM