Home >WeChat Applet >Mini Program Development >How to click and transfer value in WeChat applet
How to click and pass value in WeChat mini program
How to click and pass value in WeChat mini program:
1. First, in Use data- in wxml to add custom attributes;
2. Then bind the click event through bindtap;
3. Finally, use currentTarget in js to get the passed value.
Recommended learning: Small program development
Code example:
wxml:
data-parameter name="value"
bindtap="function name"
<view class="buy-button {{cap_select == 100 ? 'zp-active': ''}}" data-cap="100" bindtap="choose_cap"> <text>100ML \n (2两)</text> </view>
JS:
choose_cap(e) { // 通过 currentTarget 获取传递进来的值 console.log(e.currentTarget.dataset.cap); console.log(e); },
PHP Chinese website, a large number of website construction tutorials , welcome to learn!
The above is the detailed content of How to click and transfer value in WeChat applet. For more information, please follow other related articles on the PHP Chinese website!