微信小程序 点击事件 传递参数

wxml:

data-参数名="值"

bindtap="函数名"

<view class="buy-button {{cap_select == 100 ? 'zp-active': ''}}" data-cap="100" bindtap="choose_cap">
  <text>100ML \n (2两)</text>
</view>

JS:

choose_cap(res) {
  // 通过 currentTarget 获取传递进来的值
  console.log(res.currentTarget.dataset.cap);
  console.log(res);
},