我想通过一个命令在div中显示包括注释(即对象数组)的完整对象,但是注释的map函数出现错误。请帮助我....
const fields2 = [
{
month: 30,
unitrate: 2,
budget: 6000,
comments: [
{
id: 4500,
rating: 11111111111,
comment: "Imagine all the eatables, living in conFusion!",
author: "John Lemon",
date: "2012-10-16T17:57:28.556094Z"
},
{
id: 1,
rating: 22222222222,
comment:
"Sends anyone to heaven, I wish I could get my mother-in-law to eat it!",
author: "Paul McVites",
date: "2014-09-05T17:57:28.556094Z"
},
]
}
];
render() {
return (
<div>
{ fields2.map((ob,index)=>{ return (ob.month +" " + ob.comments.map((ok,index)=>{ ok } )) }) }
</div>
)
}
答案 0 :(得分:0)
您可以使用下面提到的代码
{ fields2.map((ob,index)=>{ return (ob.month +" " + JSON.stringify(ob.comments,null,4)) }) }