“无法读取与映射函数中的不确定的“错误”的属性“在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