


Detailed explanation of WeChat applet loops and nested loops
May 28, 2018 am 10:51 AMThis article mainly introduces relevant information on the use summary of WeChat applet loops and nested loops. I hope this article can help everyone. Friends in need can refer to it. I hope it can help everyone.
For us to obtain data from the interface through POST or GET requests in js and store it in the object defined in Page:
//首頁話題列表 wx.request({ url: 'https://*******************', method: 'POST', data: { pageNum: 1, pageSize: 10 }, success:function(res){ that.setData({ listTop:res.data, }) } })
In the wxml file, pass
wx:for="{{listTop}}"
To realize the loop output of data in the object, here we can get the subscript through {{index }}, or we can customize the subscript:
wx:for-index="index2"
When the object com exists in listTop, we can use wx:for ="{{item.com}}" to loop through the data in the loop.
In an actual project, I encountered such a problem: During the nested loop process, I need to convert the value of a certain field, such as the timestamp into date/a few days ago, etc. At this time, we should
Know that the WeChat applet does not support the interface to directly call JS. How should we solve it at this time:
At first, I spared a lot of trouble. I always wanted to use JS in JS. By looping it into an object, and then looping it out on the interface, I was actually close to the result in the previous step, but in actual development, I still have many shortcomings as a novice who has only been employed for less than a month, so You are trapped in an endless loop.
Solution: When you traverse, just replace the original data with the desired data. . . . (It’s very simple, but the authorities are confused, but since I solved it myself, there may be a better way, so this is just a description) WeChat development list rendering multi-layer nested loop Oracle nested loop execution plan optimization Multiple foreach nesting Loop problem The above is the detailed content of Detailed explanation of WeChat applet loops and nested loops. For more information, please follow other related articles on the PHP Chinese website!for (var i = 0; i < res.data.data.length;i++){
console.log(res.data.data[i].comments+"**********"+i)
console.log("***"+i)
if (res.data.data[i].comments !=null){
for (var j = 0; j < res.data.data[i].comments.length;j++){
res.data.data[i].comments[j].createTime=transDate(res.data.data[i].comments[j].createTime)
}
}
}
Related recommendations:

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Implementing card flipping effects in WeChat mini programs In WeChat mini programs, implementing card flipping effects is a common animation effect that can improve user experience and the attractiveness of interface interactions. The following will introduce in detail how to implement the special effect of card flipping in the WeChat applet and provide relevant code examples. First, you need to define two card elements in the page layout file of the mini program, one for displaying the front content and one for displaying the back content. The specific sample code is as follows: <!--index.wxml-->&l

Nested Generic Functions Generic functions in Go 1.18 allow the creation of functions that apply to multiple types, and nested generic functions can create reusable code hierarchies: Generic functions can be nested within each other, creating a nested code reuse structure. By composing filters and mapping functions into a pipeline, you can create reusable type-safe pipelines. Nested generic functions provide a powerful tool for creating reusable, type-safe code, making your code more efficient and maintainable.

According to news from this site on October 31, on May 27 this year, Ant Group announced the launch of the "Chinese Character Picking Project", and recently ushered in new progress: Alipay launched the "Chinese Character Picking-Uncommon Characters" mini program to collect collections from the society Rare characters supplement the rare character library and provide different input experiences for rare characters to help improve the rare character input method in Alipay. Currently, users can enter the "Uncommon Characters" applet by searching for keywords such as "Chinese character pick-up" and "rare characters". In the mini program, users can submit pictures of rare characters that have not been recognized and entered by the system. After confirmation, Alipay engineers will make additional entries into the font library. This website noticed that users can also experience the latest word-splitting input method in the mini program. This input method is designed for rare words with unclear pronunciation. User dismantling

How uniapp can achieve rapid conversion between mini programs and H5 requires specific code examples. In recent years, with the development of the mobile Internet and the popularity of smartphones, mini programs and H5 have become indispensable application forms. As a cross-platform development framework, uniapp can quickly realize the conversion between small programs and H5 based on a set of codes, greatly improving development efficiency. This article will introduce how uniapp can achieve rapid conversion between mini programs and H5, and give specific code examples. 1. Introduction to uniapp unia

How to use Vue form processing to implement recursive nesting of forms Introduction: As the complexity of front-end data processing and form processing continues to increase, we need a flexible way to handle complex forms. As a popular JavaScript framework, Vue provides us with many powerful tools and features to handle recursive nesting of forms. This article will introduce how to use Vue to handle such complex forms, and attach code examples. 1. Recursive nesting of forms In some scenarios, we may need to deal with recursive nesting.

Geolocation positioning and map display of PHP and mini programs Geolocation positioning and map display have become one of the necessary functions in modern technology. With the popularity of mobile devices, people's demand for positioning and map display is also increasing. During the development process, PHP and applets are two common technology choices. This article will introduce you to the implementation method of geographical location positioning and map display in PHP and mini programs, and attach corresponding code examples. 1. Geolocation in PHP In PHP, we can use third-party geolocation

Nested exception handling is implemented in C++ through nested try-catch blocks, allowing new exceptions to be raised within the exception handler. The nested try-catch steps are as follows: 1. The outer try-catch block handles all exceptions, including those thrown by the inner exception handler. 2. The inner try-catch block handles specific types of exceptions, and if an out-of-scope exception occurs, control is given to the external exception handler.

1. Open the WeChat mini program and enter the corresponding mini program page. 2. Find the member-related entrance on the mini program page. Usually the member entrance is in the bottom navigation bar or personal center. 3. Click the membership portal to enter the membership application page. 4. On the membership application page, fill in relevant information, such as mobile phone number, name, etc. After completing the information, submit the application. 5. The mini program will review the membership application. After passing the review, the user can become a member of the WeChat mini program. 6. As a member, users will enjoy more membership rights, such as points, coupons, member-exclusive activities, etc.
