• 小程序 之嵌套循环修改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改变

  • 相关阅读:
    Web框架&&django介绍
    bootstrap
    jQuery
    js Bom和Dom
    javascript
    css
    二分查找
    php常用函数
    基于laravel自定义测试组件
    Document
  • 原文地址:https://www.cnblogs.com/yang-2018/p/11696460.html
Copyright © 2020-2023  润新知