好友
阅读权限10
听众
最后登录1970-1-1
|
30吾爱币
请问各位大佬,后端给的数据是这样的:
[JavaScript] 纯文本查看 复制代码 [
{
"Id": 11,
"PhoneUnit": "后勤部",
"PhoneName": "张三",
"Phone": "19100000000"
},
{
"Id": 12,
"PhoneUnit": "后勤部",
"PhoneName": "李四",
"Phone": "19100000001"
},
{
"Id": 13,
"PhoneUnit": "开发部",
"PhoneName": "王五",
"Phone": "19100000002"
},
{
"Id": 14,
"PhoneUnit": "开发部",
"PhoneName": "孙权",
"Phone": "19100000003"
},
{
"Id": 15,
"PhoneUnit": "办公室",
"PhoneName": "张飞",
"Phone": "19100000004"
}
]
我想要这种格式的:
[JavaScript] 纯文本查看 复制代码 {
"后勤部": {
"employees": [
{
"Id": 11,
"PhoneUnit": "后勤部",
"PhoneName": "张三",
"Phone": "19100000000"
},
{
"Id": 12,
"PhoneUnit": "后勤部",
"PhoneName": "李四",
"Phone": "19100000001"
}
]
},
"开发部": {
"employees": [
{
"Id": 13,
"PhoneUnit": "开发部",
"PhoneName": "王五",
"Phone": "19100000002"
},
{
"Id": 14,
"PhoneUnit": "开发部",
"PhoneName": "孙权",
"Phone": "19100000003"
}
]
},
"办公室": {
"employees": [
{
"Id": 15,
"PhoneUnit": "办公室",
"PhoneName": "张飞",
"Phone": "19100000004"
}
]
}
}
新手一个,还请大佬教一下,非常感谢! |
最佳答案
查看完整内容
建议让后端处理。
[mw_shl_code=html,true]
Document
var oldList = [
{
Id: 11,
PhoneUnit: '后勤部',
PhoneName: '张三',
Phone: '19100000000',
},
{
Id: 12,
PhoneUnit: '后勤部',
PhoneName: '李四',
Phone: '19100000001',
},
...
|