wxml
<view wx:for="{{result_list}}" wx:key="key" wx:for-item="result" data-id="index">
<button id = "{{index}}" class="cu-btn round bg-blue" bindtap="collect_button">{{result.collect}}</button>
</view>
js
collect_button:function(e){
var result_list = this.data.result_list
var that = this
var id = e.currentTarget.id
for (var i = 0; i < result_list.length;i++){
if(id == i){
result_list[i]['collect'] = '已收藏'
wx.showToast({
title: '收藏成功',
duration:750
})
console.log(result_list[i])
that.setData({
result_list:result_list
})
}
}
},