首先,设置更安全的初始数据:
getInitialState : function() { return {data: {comments:[]}};},并确保您的ajax数据。
如果您按照上面的两个指示(如“
演示”)操作,它应该可以工作。
更新:您可以仅使用条件语句包装.map块。
if (this.props.data) { var commentNodes = this.props.data.map(function (comment){ return ( <div> <h1>{comment.author}</h1> </div> ); });}


