原本后台返回数据是这样:
我只想要每条数据对象的jianyanneirong和jianyannneirong1两个属性的信息:
1.使用map方法
//contentList是原本类对象数组
let a = contentList.map((val)=>{
return {
jianyanneirong: val.jianyanneirong,
jianyanneirong1: val.jianyanneirong1
}
})
console.log(a)
结果:
2.for... of 遍历数组
let resultList = []
for (const val of contentList){
let a = {}
a.jianyanneirong = val.jianyanneirong
a.jianyanneirong1 = val.jianyanneirong1
resultList.push(a)
}
console.log(resultList)
结果: