This article mainly introduces the correct usage of WeChat applet wx:for and wx:for-item. wx:for is a loop array, and wx:for-item is to assign an alias to the list. The article lists a few for you. Wrong usage, let’s learn together
wx:for="{{list}}"
is used to loop the array, and list is the array namewx:for-item= "items"
is used to define the variables of each element during a loop.
If it is a one-dimensional array, loop it out as follows:
1 2 3 |
|
In the above code, item is the alias of list.
If it is a two-dimensional or even multi-dimensional array, loop as follows:
1 2 3 4 5 6 7 8 9 |
|
is equivalent to
1 |
|
Remember: wx:for is a loop array, wx:for-item is to assign an alias to the list
The following are several incorrect uses, please use them with caution:
1. Use wx:for-item directly, so that the list will not appear in the loop
1 2 3 |
|
2. Use wx:for- with caution in sub-loops item
1 2 3 4 5 |
|
The correct usage of WeChat applet wx:for and wx:for-item
wx:for="{{list} }" is used to loop the array, and list is the array name wx:for-item="items" which is used to define the variable of each element during the loop
If it is a one-dimensional array, follow the following The method is looped out:
1 2 3 |
|
In the above code, item is the alias of list.
If it is a two-dimensional or even multi-dimensional array, loop as follows:
1 2 3 4 5 6 7 8 9 |
|
is equivalent to
1 |
|
Remember: wx:for is a loop array, wx:for-item is to assign an alias to the list
The following are several incorrect uses, please use them with caution:
1. Use wx:for-item directly, so that the list will not appear in the loop
1 2 3 |
|
2. Use wx:for- with caution in sub-loops item
1 2 3 4 5 |
|
The above is what I compiled for you. I hope it will be helpful to you in the future.
Related articles:
Ajax and mysql data interaction to create a message board function
Details of async in Ajax requests: The difference between false and async:true
Ajax implements the function of registering and selecting an avatar and then uploading it
The above is the detailed content of Detailed explanation of the usage of WeChat applet wx:for and wx:for-item. For more information, please follow other related articles on the PHP Chinese website!