小程序 for 循环。
<view wx:for="{{[1,2,3,5]}}">{{item +' '+ index}} {{index}}</view>
<view wx:for="{{6}}">{{item }} </view>
<block wx:for="{{3}}"> <button>1111</button> <view>2222</view> </block>
给item 起别名
<block wx:for="{{bums}}" wx:for-item="inner_bums"> <block wx:for="{{inner_nums}}"> <view>{{item}}</view> </block> </block>
<block wx:for="{{nums}}" wx:key="index"> <view>{{item}}</view> </block>
index 下标的用法
<view class="reduce {{item.numSub ? 'on' : ''}}" catchtap='subCart' data-index="{{index}}">-</view>
通过代码可以拿到下标
subCart:function(event){ var index = event.currentTarget.dataset.index; }
站长微信:xiaomao0055
站长QQ:14496453