【发布时间】:2019-04-08 15:27:11
【问题描述】:
我正在尝试使用带有命名空间前缀的可选 url 参数定义一个 react-router。这是此类路径的一个示例:
path="authors/:authorId/posts/:postId?"
// application.com/authors/8/posts/4
我希望 postId 变量部分是可选的,但这应该包括整个 /posts/:postId 部分是可选的。这可能吗?
【问题讨论】:
-
不是完全重复的,我的问题是关于可选的固定路径部分(我称之为命名空间)。
-
你试过
path="authors/:authorId?/posts/:postId?"吗?
标签: reactjs react-router react-router-v4 react-router-dom