不变违规:您不能嵌套路径,父级在 react-router 中需要 URL 个参数
Invariant Violation: You cannot nest path, the parent requires URL parameters in react-router
我正在尝试在 react-router 中实现以下路由:
<Route name='user' path='/:userId' handler={Profile}>
<DefaultRoute handler={Welcome}/>
<Route name='message' path='/:messageId' handler={Timeline} />
</Route>
我在控制台中收到以下错误
Uncaught Error: Invariant Violation: You cannot nest path "/:userId" inside "/:messageId"; the parent requires URL parameters
有没有办法在react-router中嵌套带参数的多个路由?
可以设置 path="/user/:userId" 吗?检查 https://github.com/rackt/react-router
中的示例
问题已通过删除消息路由中路径前面的“/”得到解决。
<Route name='user' path='/:userId' handler={Profile}>
<DefaultRoute handler={Welcome}/>
<Route name='message' path=':messageId' handler={Timeline} />
</Route>
我正在尝试在 react-router 中实现以下路由:
<Route name='user' path='/:userId' handler={Profile}>
<DefaultRoute handler={Welcome}/>
<Route name='message' path='/:messageId' handler={Timeline} />
</Route>
我在控制台中收到以下错误
Uncaught Error: Invariant Violation: You cannot nest path "/:userId" inside "/:messageId"; the parent requires URL parameters
有没有办法在react-router中嵌套带参数的多个路由?
可以设置 path="/user/:userId" 吗?检查 https://github.com/rackt/react-router
问题已通过删除消息路由中路径前面的“/”得到解决。
<Route name='user' path='/:userId' handler={Profile}>
<DefaultRoute handler={Welcome}/>
<Route name='message' path=':messageId' handler={Timeline} />
</Route>