1, wx:for
Use the wx:for control attribute on the component to bind an array, and the component can be repeatedly rendered using the data of each item in the array. By default, the subscript variable name of the current item in the array defaults to index, and the variable name of the current item in the array defaults to item. The example is as follows:
wxml file:
<view wx:for="{{items}}"> {{index}}: {{item:one}} </view> js文件: Page({ items:[{ one: "test1", },{ one: "test2" }] })
You can use wx:for -item specifies the variable name of the current element of the array
You can use wx:for-index to specify the variable name of the current subscript of the array. The example is as follows:
wxml file:
<view wx:for="{{items}}" wx:for-item="name" wx:for-index="id"> {{id}}: {{name.one}} </view> 下面是一个九九乘法表事例: <view wx:for="{{[1,2,3,4,5,6,7,8,9]}}" wx:for-item="i"> <view wx:for="{{[1,2,3,4,5,6,7,8,9]}}" wx:for-item="j"> <view wx:if="{{i <= j}}"> {{i}}*{{j}} = {{i * j}} </view> </view> </view>
2, block wx:for
wx:for is used on the
<block wx:for="{{[1,2,3]}}"> <view> {{index}}: </view> <view> {{item}} </view> </block>
Thank you for reading, I hope it can help everyone, thank you for your support of this site!
For more WeChat applet for loop detailed explanations and related articles, please pay attention to 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

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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