wxml <block wx:for-items="{{item.body}}"> <view class="zw-dp-bodyparts-class {{(index+1)%3 == 0 ? "zw-mwt-rightborder" : ""}} {{activeIndex == index ? "zw-therapy-bgfontcolor" : ""}}" bindtap="therapy" id="{{index}}"> <view class="zw-dp-vertical"> <text class="zw-ty-part-font">{{item.parts}}</text> <text>{{item.price}}</text> </view> </view> </block>
js therapy: function (e) { var activeIndex = e.currentTarget.id; console.log(activeIndex); this.setData({ activeIndex: activeIndex }); },
点击效果显示不出来,是逻辑还有问题么
1
digmon 2018-03-21 11:24:21 +08:00 via iPhone
data-id
|
2
Poikilotherm OP @digmon index 可以拿到 是我放在模板里没有传参 所以拿不到 activeIndex 了 谢谢哈
|