collection.map(function (item) {
return {item.Name} {this.getItemInfo(item)}
})
因此,
this您内部
function(item)的范围不是React组件的范围。
如果您使用箭头功能
() => {...}代替,function() {...}您将可以访问thisReact.Component。
试试这个
collection.map((item) => ( <div> {item.Name} {this.getItemInfo.call(this, item)} </div>))要了解有关
thisjavascript
范围的更多信息,可以在这里阅读:http : //javascriptissexy.com/javascript-variable-scope-
and-hoisting-explained/
要了解箭头功能和的范围
this,请参阅https://developer.mozilla.org/zh-
CN/docs/Web/Javascript/Reference/Functions/Arrow_functions的
“对此不分开”部分



