(Ix) small micro-channel program instructions for ---

For a list of data

  • wxml
<view wx:for="{{dataList}}">{{index}}-{{item}}</view>

 

We can see that the above code default to the index and item if we want to modify their own words with the following code

<view wx:for="{{dataList}}" wx:for-index="idx" wx:for-item="xxxx">{{idx+1}}-{{xxxx}}</view>

 

  • js
Page({
  data: {
    dataList: [ " mask " , " goggles " , " disinfectant " ]
  },
})

         

 

 For data dictionary

  • wxml
<view wx:for="{{userInfo}}">{{index}}-{{item}}</view>
  • js
Page({
  data: {
    userInfo:{
      name: ' Xiaoqiang ' ,
      age:18
    }
  },
})

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/a438842265/p/12347069.html