Explanation of for loop in WeChat applets

Source: Internet
Author: User
This article mainly introduces detailed information about the small program for loop. for more information about the small program for loop, see this article.

1, wx:

You can bind an array to the wx: for Control attribute on the component to repeatedly render the component using the data in the array. The subscript variable name of the current item of the default array is index by default, and the variable name of the current item of the array is item by default. The example is as follows:

Wxml file:


 
  
{Index }:{{ item: one }}
 Js file: Page ({items: [{one: "test1" ,}, {one: "test2"}]})

You can use wx: for-item to specify the variable name of the current element of the array.

You can use wx: for-index to specify the name of the variable under the array. The example is as follows:

Wxml file:


 
  
{Id }}:{ name. one }}
 The following is an example of a multiplication table:
 
  
   
    
{I }}* {j }}={ {I * j }}
   
  
 

2, block wx:

Wx: Label to render a structure block containing multiple nodes. For example:


 
  
    {{index}}: 
  
  
    {{item}} 
  
 

As follows:

Thank you for reading this article. I hope it will help you. thank you for your support for this site!

The above is a detailed explanation of the for loop of small programs. for more details, please follow other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.