我想用可选的path参数声明一个路径,因此当我添加它时,页面会做一些额外的事情(例如填充一些数据):
http://localhost/app/path/to/page<;=呈现页面
在react路由中,为了支持这两个选项,我有以下路径(这是一个简化的示例):
<Router history={history}>
<Route path="/path" component={IndexPage}>
<Route path="to/page" component={MyPage}/>
<Route path="to/page/:pathParam" component={MyPage}/>
</Route>
</Router>
我的问题是,我们可以在one路申报吗?如果我只添加第二行,则找不到没有该参数的路由.
EDIT#1:
关于以下语法的解决方案对我不起作用,它是正确的吗?文件中有吗?
<Route path="/product/:productName/?:urlID?" handler={SomeHandler} />
我的react 路由版本是:1.0.3