在使用函數式 setState 時報錯 this.setState is not a function

在react中點擊事件裏面 setState 時會使this重新定義,所以在點擊的函數裏面使用this.setState()時會報錯this.setState not a function,因此需要提前給點擊事件的函數綁定this
相關文章
相關標籤/搜索