向数组对象中添加属性

向数组infoLists中每个对象添加名为imgSrc的属性,属性值从数组imgUrl中获取

var arr = this.infoList
var curData = []

arr.forEach((item, index) => {
     
	curData.push(
		Object.assign({
     }, item, {
     ‘imgSrc’: this.imgUrl[index]})
	)
}
this.infoList = []
this.infoList = curData

 

 

 

 

 

未来还长,热血未凉

你可能感兴趣的:(js,js,数组,对象)