方法一:broserHistory.push
handleSubmit(e){
e.preventDefault();
const path = '/demo';
broserHistory.push(path);
}
方法二:context对象方法
export default React.createClass({
// ask for `router` from context
contextTypes: {
router: React.PropTypes.object
},
handleSubmit(event) {
// ...
this.context.router.push(path)
},
})
方法三:this.props.history
submitForm(e) {
e.preventDefault();
const _this = this;
_this.refs.ruleForm.validate((valid) => {
if (valid) {
_this.props.history.push('./../pages/demo');
} else {
console.log('error submit!!');
}
});
}