“無法讀取與映射函數中的不確定的“錯誤”的屬性“在React Applications中的react 中,遇到錯誤消息“ typeError:typeError:of type eRESSER:typeError:of type of typle'typle'on propert'onplayersCorechange'deplayersCorechange'未定義的“未定義”通常指示使用MAP函數時綁定的問題。以下是解決此問題的方法:
{this.state.initialplayers.map(((player,index)=> {) 返回 ( ); })}
With Bind:Alternatively, you can bind the map callback function to the React component's context manually:
{this.state.initialPlayers.map(function(player, index) { 返回 ( ); })。 bind(this)}通過實現這些方法中的任何一個,將正確綁定此上下文,允許您訪問MAP回調函數中的React Component的屬性,並避免“未定義”錯誤。
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3