其他分享
首页 > 其他分享> > bind绑定(改变this指向)

bind绑定(改变this指向)

作者:互联网

constructor(props){
    super(props)
    
    this.state=store.getState()
    this.changeInputValue=this.changeInputValue.bind(this)
    this.storeChange=this.storeChange.bind(this)
    this.clickBtn=this.clickBtn.bind(this)
    store.subscribe(this.storeChange)//订阅
  }

用bind绑定改变this指向,否则会报错(undefine....)祥见错误分类

标签:storeChange,指向,bind,绑定,changeInputValue,clickBtn,props,store
来源: https://www.cnblogs.com/Jarsmine/p/16394540.html