微信小程序双层循环获取外层索引值

<view class="list">
    <view class="item" wx:for="{
    
    {list}}" wx:key="index">
      <view class="name">{
    
    {item.name}}</view>
      <view class="star">
        <image wx:for="{
    
    {item.number}}" wx:for-index="childindex" wx:for-item="items" data-parent='{
    
    {index}}' data-childindex="{
    
    {childindex}}" bindtap="onclick" src="../../static/1.png" mode="widthFix"></image>
      </view>
    </view>
  </view>

第一层循环 wx:for="{ {data}}" wx:key="index" 索引值是index

第二层循环 wx:for="{ {item.photo}}" wx:for-index="childindex" 索引值是childindex,在第二层就可以直接取第一层的index了

猜你喜欢

转载自blog.csdn.net/weixin_47586598/article/details/129517602