var list = [{"TypeId":0,"LayoutId":LayoutId,"CoordinateX":10,"CoordinateY":10,"Width":10,"Height":10}
];if(条件一)
{
list 添加一个 {"TypeId":1,"LayoutId":LayoutId,"CoordinateX":20,"CoordinateY":20,"Width":20,"Height":20}
变成
list = [{"TypeId":0,"LayoutId":LayoutId,"CoordinateX":10,"CoordinateY":10,"Width":10,"Height":10},{"TypeId":1,"LayoutId":LayoutId,"CoordinateX":20,"CoordinateY":20,"Width":20,"Height":20}
];类似于stringbuild的append
能不能实现
}
) 不知可否
list.push(...);你那个json就是一个数组 对象啊,可以随便操作的
//你那list是Array调用push方法即可
var list = [{"TypeId":0,"LayoutId":LayoutId,"CoordinateX":10,"CoordinateY":10,"Width":10,"Height":10}
];if(条件一)
{
list.push({"TypeId":1,"LayoutId":LayoutId,"CoordinateX":20,"CoordinateY":20,"Width":20,"Height":20});
/*变成
list = [{"TypeId":0,"LayoutId":LayoutId,"CoordinateX":10,"CoordinateY":10,"Width":10,"Height":10},{"TypeId":1,"LayoutId":LayoutId,"CoordinateX":20,"CoordinateY":20,"Width":20,"Height":20}
];*/
alert(list.join('') + eval(list.join('')));//其实不用eval,本来就是array的
/*类似于stringbuild的append
能不能实现*/
}
if(dp("txtVideoWidth").value!="")
{alert("1");
list.push({"TypeId":0,"LayoutId":LayoutId,"CoordinateX":20,"CoordinateY":20,"Width":20,"Height":20});
alert(eval(list.join('')));
}
if(dp("txtPicWidth1").value!="")
{alert("2");
list.push({"TypeId":1,"LayoutId":LayoutId,"CoordinateX":20,"CoordinateY":20,"Width":20,"Height":20});
}
if(dp("txtPicWidth2").value!="")
{alert("3");
list.push({"TypeId":1,"LayoutId":LayoutId,"CoordinateX":30,"CoordinateY":30,"Width":30,"Height":30});
}
if(dp("txtPicWidth3").value!="")
{ alert("4");
list.push({"TypeId":1,"LayoutId":LayoutId,"CoordinateX":40,"CoordinateY":40,"Width":40,"Height":40});
}
if(dp("txtWidth").value!="")
{alert("5");
list.push({"TypeId":2,"LayoutId":LayoutId,"CoordinateX":40,"CoordinateY":40,"Width":40,"Height":40});
}
alert("6");
alert(list.join('') +"ppp"+ eval(list.join('')));//这里显示不出来任何数据。最后执行到alert("6");
就执行不下去了
if(dp("txtVideoWidth").value!="")
{alert("1");
list.push({"TypeId":0,"LayoutId":LayoutId,"CoordinateX":20,"CoordinateY":20,"Width":20,"Height":20});
}
if(dp("txtPicWidth1").value!="")
{alert("2");
list.push({"TypeId":1,"LayoutId":LayoutId,"CoordinateX":20,"CoordinateY":20,"Width":20,"Height":20});
}
if(dp("txtPicWidth2").value!="")
{alert("3");
list.push({"TypeId":1,"LayoutId":LayoutId,"CoordinateX":30,"CoordinateY":30,"Width":30,"Height":30});
}
if(dp("txtPicWidth3").value!="")
{ alert("4");
list.push({"TypeId":1,"LayoutId":LayoutId,"CoordinateX":40,"CoordinateY":40,"Width":40,"Height":40});
}
if(dp("txtWidth").value!="")
{alert("5");
list.push({"TypeId":2,"LayoutId":LayoutId,"CoordinateX":40,"CoordinateY":40,"Width":40,"Height":40});
}
alert("6");
alert(list.join('') +"ppp"+ eval(list.join('')));//这里显示不出来任何数据。最后执行到alert("6");