react 执行函数 获取this指向

  1. 在事件上绑定this 从而改变this 指向

  1. 在构造函数里进行绑定this
constructor(){
  super();
  this.state={
  };
  this.getData=this.getData.bind(this)
}

3.箭头函数

getData=()=>{

}

你可能感兴趣的:(react)