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); },
