toRevocateMark: function(event) { console.log(event); var index = event.currentTarget.dataset.index; var i = parseInt(index); var newss = this.data.newss; var that = this; wx.request({ url: app.globalData.baseurl + 'api/news/revocateMark', header: { 'token': wx.getStorageSync('token') // 默认值 }, data: { markid: newss[i].id }, success: function(res) { console.log(res) wx.showToast({ title: '取消成功', icon: 'none', duration: 2000 }); newss[i].isMark = 0; that.setData({ 'newss': newss }) } }) }
<text bindtap="toRevocateMark" data-index="{{index}}" wx:else>取消收藏</text>