数组重组数据
源数据:
目标数据:
// 源数据
var oldData = [
{
city_id: 1,
city_name: '北京',
city_img: "http://...dfknbdjknvkjsfnvlkjdn.png",
city_country: "中国"
},
{
city_id: 2,
city_name: '上海',
city_img: "http://...wergerbe.png",
city_country: "中国"
},
{
city_id: 3,
city_name: '广州',
city_img: "http://hrthhr.png",...: el.city_id
}
oldObj.citys.push(cityObj)
oldDataRule.push(oldObj)
})
/** * 先去重,后合并 * 1、源数据去重 * 2、把去重后的数据和源数据中相同...name的数据合并citys */
var newData = []
var newObj = {
}
oldDataRule.forEach((el, i) => {
if (!