如上图我想点击立即对换然后获取到这一条数据的数据,但是我现在点击兑换,获取到的是所有数据的值而不是这一条数据的值
<view class="activity-watch-exchange" data-index="1" bindtap="exchangeIntegral" >立即兑换</view>
async exchangeIntegral(event) {
let arrs = this.data.integralList.activitySpecial;
let query = event.currentTarget.dataset['index'];
console.log(event.currentTarget.dataset['index'],"event.currentTarget.dataset['index']");
console.log(arrs,);
for(let i of arrs){
// console.log(i.id,'i.id')
}
console.log(arrs[0].id,'i.id')
let param = {
personId:'11',
goodsId: '11111'
}
let res = await oilWeChatAppService.exchangeIntegral(param);
// debugger
if (res.success) {
wx.showToast({
title: '成功兑换',
icon: 'success',
image: '../../resource/imgs/warning.png',
duration: 2000
})
}
data-item="{{item}}"
你已经有了对应项目的 index,直接从你渲染的数组中取对应 index 的数据即可。