javascript - this.context.router.push() 不能跳转
本文介绍了javascript - this.context.router.push() 不能跳转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
代码:
class Component extends React.Component {
static contextTypes = {
router:PropTypes.object.isRequired
};
handleSubmit (e) {
...
fetch('xxx', {
...
})
.then(...)
.then((res) => {
if (...) {
this.context.router.push('xxx');
return;
...
报错:
不太明白这个报错_this2是什么意思
解决方案
this.context.router.history.push
这篇关于javascript - this.context.router.push() 不能跳转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文