search
HomeWeChat AppletMini Program DevelopmentImplementation of mini program using for loop to bind click event of item

This article mainly introduces the implementation of the click event of using the for loop to bind the item in the mini program. It has a certain reference value. Now I share it with you. Friends in need can refer to it

WeChat displays the list effect with the help of wx:for

Simple write a list (in wxml file):

 

Corresponding data source (in js file):

 

Write a click listener:

 

Effect:

 

The above can achieve the click effect of the item in the list, But the data source data corresponding to the clicked item cannot be reached

Solution:

For components with click events Add a data-any attribute any can be any data type.

As you can see from the figure below, we traverse the expertData array. Each item is defined as info. At the end of the second line, we add a sentence data-bean="{{info}}"

 

Then modify the click event:

 

I found that this method can be used to remove the data object corresponding to the clicked item, and the A certain attribute value in the object

The console prints information:

In this way, the data corresponding to an item in the list display data can be obtained.

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

The page of the mini program uses the function of nine-square grid and item jump

How to implement the mini program Let the swiper component realize the function of the carousel chart

The above is the detailed content of Implementation of mini program using for loop to bind click event of item. 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
怎么用php实现求100以内的奇数怎么用php实现求100以内的奇数Dec 23, 2022 pm 06:54 PM

实现步骤:1、使用for语句控制范围来遍历1~100的数字,语法“for ($i = 1; $i <= 100; $i++) {循环体代码}”;2、在循环体中,利用if语句和“%”运算符获取并输出奇数即可,语法“if($i % 2 != 0){echo $i." ";}”。

PHP中for循环的执行顺序是什么PHP中for循环的执行顺序是什么Sep 22, 2021 pm 06:24 PM

执行顺序:1、执行“初始化表达式”;2、执行“条件判断表达式”,如果表达式的值为真,则执行“循环体”,否则结束循环;3、执行完循环体后,执行“变量更新表达式”;4、变量更新后,进入下一次循环,直到条件判断值为假,结束循环。

JS循环学习:for循环语句的使用(示例详解)JS循环学习:for循环语句的使用(示例详解)Aug 03, 2022 pm 06:45 PM

在之前的文章《JS循环学习:while循环语句的使用(示例详解)​》中,我们简单了解了 while 循环和 do while 循环,而今天再来介绍一种循环——for 循环语句,希望对大家有所帮助!

mysql有for循环吗mysql有for循环吗Mar 30, 2023 pm 08:26 PM

mysql没有for循环,MySQL是不支持for循环语句的,只支持WHILE、REPEAT和LOOP三种循环语句,MySQL提供循环语句,允许您根据条件重复执行一个SQL代码块。

如何使用Python中的for循环如何使用Python中的for循环Oct 25, 2023 pm 12:18 PM

如何使用Python中的for循环Python是一种简单易用的编程语言,其中的for循环是非常常用的工具之一。通过使用for循环,我们可以循环遍历一系列的数据,进行有效的处理和操作,提高代码的效率。下面,我将通过具体的代码示例,介绍如何使用Python中的for循环。基本的for循环语法在Python中,for循环的语法如下:for变量in可迭代对象:

Go 处理大数组:使用 for range 还是 for 循环?Go 处理大数组:使用 for range 还是 for 循环?Jul 24, 2023 pm 02:47 PM

我们知道,Go 的语法比较简洁。它并不提供类似 C 支持的 while、do...while 等循环控制语法,而仅保留了一种语句,即 for 循环。

如何使用C语言中的for循环将数组中的偶数和奇数分开?如何使用C语言中的for循环将数组中的偶数和奇数分开?Aug 25, 2023 pm 03:09 PM

数组是一组以单一名称存储的相关数据项。例如intStudent[30];//student是一个数组名,包含单个变量名的30个数据项集合数组的操作搜索-用于查找特定元素是否存在排序-它有助于排列数组中的元素按升序或降序排列。遍历-它按顺序处理数组中的每个元素。插入-它有助于在数组中插入元素。删除-它有助于删除数组中的元素。数组中的元素。在数组中查找偶数的逻辑如下-for(i=0;i<size;i++){&nbsp;&nbsp;if(a[i]%2==0){&nbsp;

如何在Go语言中利用for循环实现翻转操作如何在Go语言中利用for循环实现翻转操作Mar 24, 2024 pm 02:15 PM

标题:Go语言中利用for循环实现翻转操作的方法在Go语言中,通过使用for循环可以很方便地对数组、切片等数据结构进行翻转操作。在本文中,我们将介绍如何利用for循环来实现数组和切片的翻转,并给出具体的代码示例。翻转数组的操作首先,我们来看如何通过for循环实现数组的翻转操作。我们定义一个包含整型元素的数组,并使用for循环将其翻转。packagemain

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.