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

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MantisBT

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.