|
react事件触发的跳转
1.在不考虑版本问题,可以用:window.location.href="./路径" 2.低版本的是react-router,可以采用:this.props.router.push(path)或this.context.router.push(path) 3.目前的react-router-dom,可采用:this.props.history.push(path),传参的话this.props.history.push(path,参数) 另一组件获取方式:this.props.location.state。 也可以用this.props.history.go(1/-1)实现下一页或者上一页 react,router默认页面 1.低版本的,可以采用<IndexRoute component={组件}/>或者利用url来判断 2.用重定向(Redirect),会出现报错,目前版本只需要加上exact就行了,也不会出现报错情况如(图1) 图片:2018-08-27_001241.png
|
|
|
沙发#
发布于:2018-08-29 20:25
path(string): 路由匹配路径。(没有path属性的Route 总是会 匹配);
exact(bool):为true时,则要求路径与location.pathname必须完全匹配; strict(bool):true的时候,有结尾斜线的路径只能匹配有斜线的location.pathname; |
|
|
