class
(类名)的三元表达式
1、实现效果:
当currentSortIndex
等于index
时,加上类名selectedSort
2、实现代码:
第一种方法:
<view class="wx:if='{{currentSortIndex == index ? 'selectedSort' : ''}}' " wx:for="{{selections}}" wx:key="index" data-index="{{index}}" catchtap="selectSort">{{item}}</view>
第二种方法:
<view class="{{currentSortIndex == index ? 'selectedSort' : ''}}" wx:for="{{selections}}" wx:key="index" data-index="{{index}}" catchtap="selectSort">{{item}}</view>