Home  >  Article  >  WeChat Applet  >  How to click and transfer value in WeChat applet

How to click and transfer value in WeChat applet

angryTom
angryTomOriginal
2020-03-23 12:15:033727browse

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"


  100ML \n (2两)

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn