【发布时间】:2019-01-28 09:12:54
【问题描述】:
我想通过一个命令在 div 中显示完整的对象,包括 cmets(它是对象数组),但我在 cmets 的 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>
)
}
【问题讨论】:
-
{ fields2.map((ob,index)=>{ return (ob.month +" " + JSON.stringify(ob.cmets)) }) }
标签: reactjs