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 } },