小程序 之嵌套循环修改index与item

    <block wx:for="{{menu}}" wx:key="index">
      <view class="cate-item {{item.isActive ? 'active': ''}}" bindtap="selectCategory" data-index="{{index}}" data-flag="0">
        <view class="title">
          <text class="font-size14">{{item.typename}}</text>
          <view class="arrow-wrap" wx:if="{{item._child.length > 0}}">
            <text class="fa fa-caret-down font-size16" style="color: #d6d6d7;"></text>
          </view>
        </view>
        <view class="child-lists" wx:if="{{item._child.length > 0}}" style="display: {{item.isChildActive ?  'block' : 'none'}};">
          <block wx:for="{{item._child}}" wx:key="child" wx:for-index="index2" wx:for-item="i">
            <view catchtap="selectCategory" data-index="{{index}}" data-childIndex="{{index2}}" data-flag="1" class="cate-sub-item {{i.isActive ? 'active': ''}}">
              <view class="sub-title">
                <text>{{i.typename}}</text>
              </view>
            </view>
          </block>
        </view>
      </view>
    </block>

通过 wx:for-index 和 wx:for-item改变

 

posted @ 2019-10-18 09:21  样子2018  阅读(2590)  评论(0编辑  收藏  举报