微信小程序的点击添加样式,多个选择
作者:
加冰宝贝 | 来源:发表于
2019-01-02 23:10 被阅读77次 view class="flex-wrap" wx:for="{{comments}}" wx:key="{{comments}}">
<image mode='widthFix' src="{{item.url}}"></image>
<view class="left">
<view class="top">
<view>{{item.name}}</view>
<view>{{item.number}} <text wx:for-index="index" data-index="{{index}}" bindtap='dianji' class="iconfont icon-zan" style="{{item.checked?'color:red;':'color:#bfbfbf;'}}"></text></view>
</view>
<view class="bottom">
{{item.contents}}
</view>
//js
dianji:function(e){
console.log(e.currentTarget.dataset.index)
var index = e.currentTarget.dataset.index
var comments = this.data.comments
var that = this
comments[index].checked = !comments[index].checked
that.setData({
comments: comments
})
console.log(comments[index].checked)
}, //音乐
本文标题:微信小程序的点击添加样式,多个选择
本文链接:https://www.haomeiwen.com/subject/kpcxrqtx.html
网友评论