for(let i in res.requestFields){
var reqArr = [];
var propObj ={};
for(var a =0;a<$(".childrenProp").length;a++){
if($(".childrenProp").eq(a).attr("data-class") == res.requestFields[i].id){
propObj[$(".childrenProp").eq(a).attr("data-prop")]=$(".childrenProp").eq(a).val();
console.log(propObj)
}
}
reqArr.push(propObj);
console.log(reqArr)
ReqObj[res.requestFields[i].id]=reqArr;
}
console.log(ReqObj)
求解,我这个 for 循环 json 添加数据被覆盖,该怎么写
propObj[$(".childrenProp").eq(a).attr("data-prop")]=$(".childrenProp").eq(a).val();
1
tonghuazhen OP ![微信截图_20180522190558.png]( https://i.loli.net/2018/05/22/5b03f9c22b8bf.png)
|