关于 react-rounter 4.1.1的问题
来源:9-1 路由配置
joya0
2017-05-24
<Route path='/search/:category(/:keyword)' component={Search}/>
(/:keyword)是选填参数,可有可没有
hashHistory.push('/search/all/' + encodeURIComponent(value)),进行页面的跳转
但我的react-router 是4.1.1的版本,没有hashHistory和(/:keyword)是选填参数,我应该怎样实现?
hashHistory.push('/search/all/' + encodeURIComponent(value)) 改成 location.href = xxx 么?那路由这块应该怎么写呢?
2回答
-
仅供参考哈 https://github.com/Hydraz320/react-dp-webapp/blob/master/docs/react-routerV4%E5%8F%AF%E9%80%89URL%E7%9A%84%E7%94%A8%E6%B3%95.md
012017-05-24 -
joya0
提问者
2017-05-24
<HashRouter>
<Switch>
<Route path="/" exact component={Home}/>
<Route path="/city" component={City}/>
<Route path="/search/:category" exact strict component={Search}/>
<Route path="/search/:category/:keyword" component={Search}/>
<Route path="/detail/:id" component={Detail}/>
<Route component={NotFound}/>
</Switch>
</HashRouter>
我路由是这样写的
032017-05-25
相似问题