后端返回数据,遍历数组,只取对象中某几个属性
原数组对象为
Arr =[
{id:1,name:恰恰, num:100, age:28,sex:'1'},
{id:2,name:嘻嘻, num:200, age:29,sex:'2'},
{id:3,name:哈哈, num:300, age:30,sex:'1'}
]
let newArr =[]
this.newArr = this.Arr .map((item) =>{ return Object.assign({},{'name':item.name,"age":item.age}) })
//最后得到的数组为:
newArr =[ {name:恰恰, age:28}, {name:嘻嘻, age:29}, {name:哈哈, age:30} ]