替换数据中所有front_name 改为 label(包括lab内的front_name)
var kvArray = [
{key: 1, value: 10, front_name:'出库', lab:[{id: 1, front_key: "chuku-list", front_name: "出库列表1"},{id: 2, front_key: "chuku-list", front_name: "出库列表2"}]},
{key: 2, value: 20, front_name:'入库', lab:[{id: 1, front_key: "chuku-list", front_name: "入库列表1"},{id: 2, front_key: "chuku-list", front_name: "入库列表2"}]},
{key: 3, value: 30, front_name:'存库', lab:[{id: 1, front_key: "chuku-list", front_name: "存库列表1"},{id: 2, front_key: "chuku-list", front_name: "存库列表2"}]}
];
var reformattedArray = kvArray.map(function(obj) {
var rObj = {};
rObj['label'] = obj.front_name;
return rObj;
});
console.log( JSON.stringify(reformattedArray) )
没太理解你的提问,如果是指将front_name这个属性名改成label的话,试试下面这样。