路由跳转this.props.history.push('');
export default class IndexView extends React.Component {
route = () => {
this.props.history.push('/my/login',{
data:111
});
console.log("跳转成功!");
}
render() {
return (
<div>
<Contextmy></Contextmy>
<input type = "button" onClick = {() => {this.route()}} value = "登录"/>
</div>
)
}
}
/my/login.jsx页面:
render() {
console.log(this.props.location.state.data);
return (
<div>
<p>欢迎登录</p>
</div>
)
}
打印结果: