react-router4.2 以前版本的实现方式
this.props.history.push('/chat');
react-router4.2 以后版本的实现方式
import PropTypes from "prop-types";
class Bottom extends Component{
//跳转方式一
static contextTypes = {
router: PropTypes.object.isRequired,
}
render(){
return(
<div className="bottom">
<a href="index.html" className="btn btn-bg black-btn fiexd-left-btn">Prev</a>
<a id="btn_confirm" onClick={this.confirmBtn.bind(this)} href="#" className="btn btn-bg blue-btn fiexd-right-btn">Next</a>
</div>
)
}
confirmBtn = ()=>{
var check1 = document.getElementById("check1");
if(!check1.checked){
alert("请确认你已经阅读完了上面的安全提示");
return;
}
//跳转方式一
this.context.router.history.push('/scan-cardInfo');
}
}