关于react使用hashRouter父子组件中子组件点击按钮后路由跳转)
HashRouter基本代码
<HashRouter>
<Routers history={history}>
<Route exact path="/" component={Index}/>
<Route path="/father" component={Father}/>
</Routers>
</HashRouter>
class Router extends Component{
render(){
return(
{this.props.child}
)
}
}
父组件基本代码
class Father extends Component{
constructor(props){
super(props);
}
change(state){
this.props.history.push({pathname:'/',state:state})
}
render(){
return(
<div>
<Child onClick={this.change.bind(this)} />
</div>
)
}
}
子组件基本代码
class Child extends Component{
constrcutor(props){
super(pr