<view class="bangDingItem" wx:for="{{oldManHistoryList}}" wx:key="id"> <view class="bangDingTitle" bindtap="oldManListTap" data-source="{{item}}"> <wux-row> <wux-col span="6" push="0"> <view class="icon "> <wux-icon type="ios-paper" size="40rpx" /> </view> </wux-col> <wux-col span="6" pull="4"> <text class="name"> 姓名:{{item.xinMings}} </text> </wux-col> </wux-row> <text class="idcardNum "> 身份證號:{{item.cardNumber}} </text> </view> </view>
這是一個簡單的列表生成代碼,我們對item進行了bindtap綁定,那么如何在js點擊里拿到當前item數據呢
查詢wechat官方文檔我們可以有點頭緒
在事件點擊中我們可以在view屬性里聲明 data- + 一個關鍵字,這樣在點擊監聽觸發后,可以在js中取到當前item的數據了
console.log(event.currentTarget.dataset.source)
這樣將可以拿到整個item的數據
至此,渲染列表 點擊監聽問題結解決了