【发布时间】:2016-09-27 11:58:29
【问题描述】:
在我的 React-router-redux-redial 应用程序中,我们可以使用两个 url:
- /accountId
- /accountId/语言
语言是可选的。
当没有设置语言参数时,我们必须强制使用“fr”语言。
react-router 是否有可能自动将“/accountId”转发到“/accountId/fr”?
IndexRoute 没有任何路径属性来强制 url 并且重定向功能不适合我们的需求,出于某些 SEO 原因,我们希望在 url 中看到“/accountId/fr”。
我试图在我的 LandingCmp 的渲染函数中进行 dispatch(push("/accountId/fr")) 但它不起作用。
我们使用重拨 (@provideHooks) 来确保在服务器端进行干净的预渲染。
这是我当前的路由表:
<Route path='/'>
<Route path="error" component={ErrorsCmp} />
<Route path=":accountId">
<Route path=":langue">
<IndexRoute component={LandingCmp} />
</Route>
<IndexRoute component={LandingCmp} />
</Route>
</Route>
我们使用以下依赖项: - “react-router-redux”:“4.0.5” - “反应路由器”:“2.7.0”
【问题讨论】:
标签: reactjs react-router