for (let i = 0; i < this.tableData.length; i++) {const itemList = this.tableData[i] as any;const newkey: any = Object.keys(itemList).sort(function compareFunction(item1,item2) {return item1.localeCompare(item2);});const newObj = {} as any; //创建一个新的对象,用于存放排好序的键值对//遍历newkey数组for (let i = 0; i < newkey.length; i++) {//向新创建的对象中按照排好的顺序依次增加键值对newObj[newkey[i]] = itemList[newkey[i]]; }const newList = [] as any;Object.keys(newObj).map((item: any) => {const obj = {name: item,value: newObj[item], } as any;newList.push(obj);});console.log(newList);//处理好的json对象数组}
1200字范文,内容丰富有趣,写作的好帮手!