我有一个这样的数组
var data = [
{
name: "Movies", info: "category_name",
content: [
{ name: "Interstellar", info: "category_data" },
{ name: "Dark Knight", info: "category_data" },
]
},
{
name: "Music", info: "category_name",
content: [
{ name: "Adams", info: "category_data" },
{ name: "Nirvana", info: "category_data" },
]
},
{
name: "Places", info: "category_name",
content: [
{ name: "Jordan", info: "category_data" },
{ name: "Punjab", info: "category_data" },
]
},
]
并且想把它变成这样
var transformedArray= [
{ name: "Movies", info: "category_name" },
{ name: "Interstellar", info: "category_data" },
{ name: "Dark Knight", info: "category_data" },
{ name: "Music", info: "category_name" },
{ name: "Adams", info: "category_data" },
{ name: "Nirvana", info: "category_data" },
{ name: "Places", info: "category_name" },
{ name: "Jordan", info: "category_data" },
{ name: "Punjab", info: "category_data" },
]
我不知道适合这种情况的关键字是什么,我尝试将其映射到新数组中,但与我预期的不一样
var newArr = []
var manipulate = data.map(item => {
return (
newArr.push(item),
new1.map(items => {
return (
new1.push(items)
)
})
)
})
那么如何将“数据”操作为“transformedArray”
四季花海
慕慕森
相关分类