当报错这个的时候就要看函数是否在行内绑定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)  //这里一定要写等于
}

问题见这里:https://segmentfault.com/q/1010000015903657

相关文章:

  • 2022-12-23
  • 2021-04-08
  • 2021-10-25
  • 2021-10-03
  • 2021-12-11
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-12
  • 2021-09-11
  • 2022-12-23
  • 2021-09-14
  • 2022-12-23
  • 2021-06-30
  • 2021-05-15
相关资源
相似解决方案