当报错这个的时候就要看函数是否在行内绑定this,或者在constructor中绑定this。
我这里犯的错误的是虽然我在constructor中绑定了this,但是语法写的不正确。
错误示范:
constructor(props){
super(props);
this.state = {
keyword:this.props.match.params.id,
result:"true",
_isMounted:true
};
this.handleFetch.bind(this) //看这里
}
正确写法:
constructor(props){
super(props);
this.state = {
keyword:this.props.match.params.id,
result:"true",
_isMounted:true
};
this.handleFetch=this.handleFetch.bind(this) //这里一定要写等于
}
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有