得到的json例如这样`var tempData=[{FieldDes:"男",FieldName:"Male",Unit:"人",Value:4},{FieldDes:"女",FieldName:"Female",Unit:"人",Value:3}]`;利用js怎么转化成适合在页面上绑定的结构?例如转化成var tempData={Male:4,Female:3}这样的
1 回答
慕慕森
TA贡献1856条经验 获得超17个赞
var tempData = [
{
FieldDes: "男",
FieldName: "Male",
Unit: "人",
Value: 4
}, {
FieldDes: "女",
FieldName: "Female",
Unit: "人",
Value: 3
}
]
let result = {}
tempData.forEach(item => result[item.FieldName] =item.Value)
添加回答
举报
0/150
提交
取消