items: [{
title: "north panel",
html: "上",
region: "north",
height: 50
}, {
title: "south panel",
html: "下",
region: "south",
height: 50
}, {
title: "west panel",
html: "左",
region: "west",
width:100
}, {
title: "east panel",
html: "右",
region: "east",
width: 100
}, {
title: "center panel",
html: "中",
region: "center"
}]
想写成这个样子,应该怎么写js文件呢?
你是想要json对象么?不如在java代码写个实体类,用list装这个实体类,然后通过Gson自动转换为Json对象传到页面
表示不懂你要表述什么?
提问要素:
想要达到的目的,
简述遇到的问题,
已经尝试过的解决方案
哎,,,题主这个话确实没说完,,,
提供一下参考资料,,(对象也同理)
//数组转json串
var arr = [1,2,3, { a : 1 } ];
JSON.stringify( arr );
//json字符串转数组
var jsonStr = '[1,2,3,{"a":1}]';
JSON.parse( jsonStr );
var items= [{
title: "north panel",
html: "上",
region: "north",
height: 50
}, {
title: "south panel",
html: "下",
region: "south",
height: 50
}, {
title: "west panel",
html: "左",
region: "west",
width:100
}, {
title: "east panel",
html: "右",
region: "east",
width: 100
}, {
title: "center panel",
html: "中",
region: "center"
}]
楼主是要这样一个对象? 直接写不就完了? 感觉没理解楼主的意思!
楼主可以创建一个数组,在创建数个对象,然后将对象添加至数组内
LZ可以参考一下楼上的~