詳細可以參考官方文檔
https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxml/event.html#%E4%BA%8B%E4%BB%B6%E7%9A%84%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F
簡單來說,在wxml中通過 data-… 來綁定屬性, 這裏我用了data-id
<view class="itemBox" wx:for="{{notices}}">
<view class="title" bindtap="noticePage" data-id="{{item.id}}">{{item.title}}</view>
</view>
在js文件中 通過 detail.currentTarget.dataset[ ’ … '] 來獲取 dataset[ ‘id’] 中的id和wxml中我們寫的data-id是對應的
noticePage:function(detail){
console.log( detail.currentTarget.dataset['id']);
},