标签:list use javascrip app code log nload asc hello
读取json选项卡:
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 //获取应用实例 var app = getApp() Page({ data: { motto: ‘Hello World‘, userInfo: {}, oneList:[{ id:1, name:‘周杰伦‘ },{ id:2, name:‘彭于晏‘ },{ id:3, name:‘蔡依林‘ },{ id:4, name:‘林俊杰‘ }], }, 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 }); }, })
标签:list use javascrip app code log nload asc hello
原文地址:http://www.cnblogs.com/flower46273736/p/6322546.html