微信小程序二維for循環


轉載自https://blog.csdn.net/Sensation_cyq/article/details/77507831

data: {
groups: [
 [
  {
  title: '狼圖騰',
  cover: '../../img/mineBG.png'
  },
  {
  title: '狼圖騰',
  cover: '../../img/mineBG.png'
  },
 ],
 [
  {
  title: '狼圖騰',
  cover: '../../img/mineBG.png'
  },
 ],
 [
  {
  title: '狼圖騰',
  cover: '../../img/mineBG.png'
  },
 ]
],
},

<!--一共三組-->
<view class="group" wx:for="{{groups}}"  wx:for-index="groupindex">
 
  <!--組頭-->
  <view class="group-header">
    <view class="group-header-left">{{}}</view>
    <view class="group-header-right">{{}}</view>
  </view>
<br><br><br>MARK:<br>二級循環的時候,wx:for="item",這種寫法是錯誤的。<br><br>
  <!--cell-->
  <view class="group-cell" wx:for="{{groups[groupindex]}}" wx:for-item="cell" wx:for-index="cellindex">
    <!--<image class='group-cell-image' src="{{item.cover}}"></image>-->
    <image class='group-cell-image' src="../../img/mineBG.png"></image>
    <view class='group-cell-title'>title{{cell.title}}</view>
  </view>
 
  <!--footer-->
  <view class="group-footer">{{group.footer}}</view>
</view>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM