Applet wx: key in * this keyword

"Keep on behalf of * this keyword in a for loop in the item itself, which expressed the need for item itself is a unique string of numbers or, if the object is not possible

data:{

  array:[1,2,3,4,5],

  objs:[{id:1},{id:2},{id:3},{id:4}]

}

<block wx:for="{{array}}" wx:key="*this">

  <view>{{item}}</view>

</block>

 

<block wx:for="{{objs}}" wx:key="{{item.id}}">

  <view>{{item.id}}</view>

</block>

 

wx: value for key is provided in two forms

  1. String that represents a property of the for loop in Array of item, the value of the property needs to be unique in the list of strings or numbers, and can not be changed dynamically.

  2. * This represents the reserved keywords for circulation in the item itself, which expressed the need for item itself is a unique numeric or string

Guess you like

Origin www.cnblogs.com/wangshuazi/p/11024661.html