<head>
<title>无标题</title>
</head>
<body>
<script type="text/javascript">
var ac = ['id1','id2']
var ad = ['title1','title2']
var ae = ['uid1','uid2']
var af = ['utitle1'消薯,'utitle2']
var r=[]
for(var i=0i<ac.lengthi++)
r.push({id:ac[i],title:ad[i],ulist:[{uid:ae[i],utitle:af[i]}]})
//输出,以进行核对
document.write("[")
for(var i=0i<r.lengthi++)
{
document.write("{")
document.write("id:'"+r[i]['id']+"',")
document.write("title:'"+r[i]['title']+"',")
document.write("ulist:[{uid:'"+r[i]['ulist'][0]['uid']+"销桥猜',")
document.write("utitle:'"+r[i]['ulist'][0]['utitle']+"'}]")
document.write("}")
if(i!=r.length-1)
document.write(",<br />")
}
document.write("]")
<亏型/script>
</body>
</html>
通告没山过wx.request获取到服袜中务器数据之后将数据(一个json对象)绑定至post数组,然后页面中获取数据的时候可以直接通过(数组名.属性)直接取值。数组中有多个json对象的话,则需要wx:for遍历取值。单个json对象察中数据绑定
页面取值:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)