小程序 for循环

for指令

  • wxml

    <!--pages/goods/goods.wxml-->
    <text>商品列表</text>
    <view>
      <view wx:for="{{dataList}}" >{{index}} -  {{item}}</view>
      <view wx:for="{{dataList}}" wx:for-index="idx" wx:for-item="x">{{idx}} -  {{x}}</view>
    </view>
    <view>
      {{userInfo.name}}
      {{userInfo.age}}
    </view>
    <view>
      <view wx:for="{{userInfo}}">{{index}} - {{item}}</view>
    </view>
    
    
  • js

      data: {
        dataList:["白浩为","海狗","常鑫"],
        userInfo:{
          name:"alex",
          age:18
        }
      },
    
posted @ 2021-05-01 22:01  AngDH  阅读(75)  评论(0编辑  收藏  举报