说我有http://www.example.com/page/#/search
路由这样的:在传递可选参数反应路由器
<Router history={hashHistory}>
<Route path='/search/' component={SearchPage} />
</Router>
而当用户确实使用提供name
和age
搜索框的页面上的搜索(无论是可以被排除在外,或两者都可以填充),我希望它重定向到:
http://www.example.com/page/#/search/?name=whatever%20name&age=15
这将显示此特定搜索的结果。这也将允许直接链接到搜索结果。
现在在我的SearchPage
组件中,我如何检查是否已提供?name=
或?age=
或任何其他搜索参数?