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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment