<block wx:for="{{nums}}" wx:for-index=‘key‘ wx:for-item=‘item‘> <view class="maxbox" bindtap="imgchange" id="{{key}}"> <text class="nums">{{item.num}}</text> </view> </block>
Page({ data: { nums:[ {num:11}, {num:22} ] }, imgchange: function (event) { //获取当前item的下标id 通过currentTarget.id var id = event.currentTarget.id; console.log(id); var nums = this.data.nums[id].num; console.log(nums); }, })
原文地址:https://www.cnblogs.com/wcLT/p/9057034.html
时间: 2024-11-13 01:13:33