var a=[];
for(var i=0;i<7;i++){
var data={"name":"张"+i,"age":i};
a.push(data);
}
//结果为:[{name:张0,age:0},{name:张1,age:1},{name:张2,age:2},{name:张3,age:3},{name:张4,age:4}.......]
动态生成json数组
最新推荐文章于 2021-06-02 15:49:46 发布
var a=[];
for(var i=0;i<7;i++){
var data={"name":"张"+i,"age":i};
a.push(data);
}
//结果为:[{name:张0,age:0},{name:张1,age:1},{name:张2,age:2},{name:张3,age:3},{name:张4,age:4}.......]