Now you can provide attr `wx:key` for a `wx:for` ?
WXMLRT_$gwx:./weui-miniprogram/tabbar/tabbar.wxml:view:3:4: Now you can provide attr `wx:key` for a `wx:for` to improve performance.
什么意思
<view class = "weui-tabbar {{extClass}}" > <!-- 选中的时候往weui-tabbar__item加 class :weui-bar__item_on --> <view data-index= '{{index}}' bindtap= "tabChange" wx: for = "{{list}}" class = "weui-tabbar__item {{index === current ? 'weui-bar__item_on' : ''}}" > <view style= "position: relative;display:inline-block;" > <image src= "{{current === index ? item.selectedIconPath : item.iconPath}}" class = "weui-tabbar__icon" ></image> <mp-badge wx: if = "{{item.badge}}" content= "{{item.badge}}" style= "position: absolute;top:-2px;left:calc(100% - 3px)" ></mp-badge> </view> <view class = "weui-tabbar__label" >{{item.text}}</view> </view> </view> |
要加wx:key="index",跟react中的key可以一样,有利于渲染性能的。
wx:for 要加 wx:key="index"