Read the JSON tab:
Index.wxml
<!--index.wxml--><view class= "Top" wx:for= "{{onelist}}" wx:for-item= "I" wx:for-index= "id" data-id= "{{ I.id-1}} "wx:key=" id "bindtap=" add "> {{id}} </view><view class=" Bottom "> {{id}}:{{ Onelist[id].name}}</view>
Index.wxss
/**index.wxss**/.top{width:23%;float:left;line-height:100rpx;background: #f60; Text-align:center;color: #fff; margin:0 1%;}. Bottom{width:100%;height:400rpx;background: #f90}
Index.js
index.js//Get app instance var app = Getapp () Page ({ data: { motto: ' Hello World ', userInfo: {}, onelist:[{ Id:1, name: ' Jay Chou ' },{ id:2, name: ' Peng ' },{ id:3, name: ' Jolin Tsai ' },{ id:4, name: ' JJ Lin ' }], }, onload:function () { console.log ("OnLoad"); This.setdata ({ id:0 });}, add:function (e) { console.log (e.target.dataset.id); This.setdata ({ id:e.target.dataset.id });})
Recently developed small program written by demo