微信小程序动态的数据实现排他
//html
<view class="charge">
<view class="charge-item" wx:for="{{dataList}}" wx:key="{{index}}" bindtap="choiceTab" id="{{index}}" >
<block wx:if="{{index==clickId}}">
<view class="pay-active" ></view>
</block>
<view class="charge-money">{{item.num}}</view>
<view>{{item.acitve}}</view>
</view>
</view>
//js
data:{
dataList: [{
acitve: '充300元送20元',
num: '300元'
}, {
acitve: '充200元送10元',
num: '200元'
}, {
acitve: '充100元送20元',
num: '100元'
}
],
clickId:-1,//默认不选中
}
//tab
choiceTab: function (event){
console.log(event.currentTarget.id)
this.setData({
clickId: event.currentTarget.id,
})
},