data1: [ { appName: '应用1', capacity: 233456 }, { title: '应用2', key: 124535 }]
data2: [ { name: '应用1', value: 233456 }, { name: '应用2', value: 124535 } ]
convertKey (arr, key) {
let newArr = [];
arr.forEach((item, index) => {
let newObj = {};
for (var i = 0; i < key.length; i++) {
newObj[key[i]] = item[Object.keys(item)[i]]
}
newArr.push(newObj);
})
console.log(newArr)
return newArr;
}
let data2 = convertKey(data1, ['name', 'value']);