1.数组里遍历,组成新数组
this.name = data.map(item => {
return item.name
});
2.遍历数组给数组每个对象添加新的键值
this.refundNumberDetailData=this.refundNumberDetailData.map(item => {
//解构item,且给item添加新的值 refundNum,键值(refundNum: item.num)
//这里解构相当于把item里面的值都拿出来重新赋值
return { ...item,refundNum: item.num }
})
字符串截取转数组:
var array = data.wpzp.split(',');
循环数组替换key
let newList = lists.map(item => { return { id: item.id, itemName: item.name} })
对象拼接:
Object.assign( obj1, obj2);
根据id找name:
var name = type.filter( items => items.id === id)[0].name