大佬教程收集整理的这篇文章主要介绍了使用 React 读取嵌套数组并显示项目,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我无法用正确的数组信息填充
这是更正后的文件。
renderComments(){
if (this.props.SELEcteddish != null) {
const commentList = this.props.SELEcteddish.comments;
return (
<div>
<h4>Comments</h4>
{CommentList.map((comment) => {
return (
<ul classname="List-unstyled" >
<li>
<p>{Comment.comment}</p>
<p> -- {Comment.author}{" "}
{Intl.datetiR_49_11845@eFormat("en-US",{
month: "short",day: "2-digit",year: "numeric"}).format(new Date(comment.datE))}
</p>
</li>
</ul>
);
})};
</div>
);
} else {
return (
<div></div>
);
}
}
谢谢sava128
您应该像对 dish.name and dish.description
一样分配评论
试试:
renderComments() {
const dish = this.props.SELEctedDish;
if (dish) {
const commentList = dish.comments;
console.log("test2",commentList);
return (
<div>
<h4>Comments</h4>
<ul className="list-unstyled">
{CommentList.map((comment) => {
return (
// list items here
)
})}
</ul>
</div>
);
} // else here
}
以上是大佬教程为你收集整理的使用 React 读取嵌套数组并显示项目全部内容,希望文章能够帮你解决使用 React 读取嵌套数组并显示项目所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。