我在react项目中有一些数据,我需要在列表中显示标题。
以下是数据:
const data = [
{
"things":[
{
"id":"1",
"subdata":{
"date":{
"exp":"2018-17-23"
},
"titles":[
{
"title":"title1"
},
{
"title":"title2"
}
]
}
}
]
}
]
方法中列出标题值。
{ title value here }循环?
发布于 2018-10-24 05:45:08
要迭代第一件事的标题并将其记入日志:
data[0].things[0].subdata.titles.forEach(obj => {
console.log(obj.title)
})
发布于 2018-10-24 05:48:29
data[0].things.map(({ subdata }) => subdata.titles.map(({ title }) => console.log(title)))
发布于 2018-10-24 05:51:16
data[0].things[0].subdata.titles.forEach(obj => console.log(obj.title));
https://stackoverflow.com/questions/52958207
复制相似问题