我是使用 React 的新手,在我的應用程式中使用搜索底部時遇到此錯誤。 這是錯誤
這是我的代碼
代碼
[在此處輸入圖片描述][3] 我也是 stackoverflow 的新手,如果您需要更多資訊,請告訴我。
謝謝你。
uj5u.com熱心網友回復:
有幾種方法可以解決此問題:
- 改用箭頭函式:
search = (terms) => {}
- 系結
this到您打算this.search = this.search.bind(this);在您的 App constructor() 之后使用的函式this.state
查看更多詳細資訊:React - How to fix this.setState is not a function error
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/479825.html
標籤:javascript 反应
