1. 程式人生 > >微信小程式的迴圈遍歷

微信小程式的迴圈遍歷

imgUrls:[
      '../../images/slide/banner1.jpg'
    ],
    contentItems:[
      "../../images/index/01.jpg",
      "../../images/index/02.jpg"
    ],
    aa:[
      {
        id: 1,txt: "ss", src : "../../images/index/01.jpg"
      },
      {
        id: 2,txt: "ssxx", src: "../../images/index/02.jpg"
      }
    ]

wxml

<view class='content'>
      <view class='content-item' wx:for="{{aa}}" id='{{index}}' bindtap=''>
        <image src='{{item.src}}'></image>
        <view class='content-item-text'>
          <text>{{item.txt}}</text>
        </view>
      </view>
    
    </view>