【发布时间】:2020-12-20 14:38:47
【问题描述】:
我正在尝试在反应路由器中使用嵌套路由。但我的嵌套 routig 不起作用。如果那会有所不同,我正在使用 Typescript。
//This is working
<Route exact path={path} component={StudentList}></Route>
//This is not working
<Route path={`${path}/:id`} component={StudentComponent}></Route>
我有一个名为 StudentModule 的模块。在模块 a 中,当我路由到时,有两条类似上面的路由
/students/1 没有渲染
我在 CodeSandbox 上创建了一个示例应用 https://codesandbox.io/s/vibrant-pasteur-n1eq7
要查看问题所在,请导航至菜单中的学生,然后单击学生。它需要渲染 StudentComponent 并在屏幕上写入Student works。
请帮我看看我的代码有什么问题?
【问题讨论】:
标签: react-router react-router-dom nested-routes