在 wx:for 循环中添加 data-index="{{index}}"
注:data-index="{{index}}" 必须在绑定 bindtap 点击事件的 view 才能生效
<view wx:for="{{purchase}}" data-index="{{index}}" wx:key="unique" bindtap="detailPurchase"><text>{{item.planId}}</text><view>详细地址:{{item.address}}</view><view>{{item.timeStart}}~{{item.timeEnd}}</view></view>
带参数跳转采购详情页面
detailPurchase: function(event) {const index = event.currentTarget.dataset.indexconst planId = this.data.purchase[index].planIdwx.switchTab({ url: `/pages/home/home?planId=${planId}`})},