In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article, the editor introduces in detail "how WeChat Mini Programs realizes the cycle and nested cycle". The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to achieve the cycle and nested cycle by WeChat Mini Programs" can help you solve your doubts. Let's follow the editor's ideas slowly and deeply, together to learn new knowledge.
Summary on the use of WeChat Mini Programs cycle and nested Loop
With regard to WeChat Mini Programs, he was recently arranged to be WeChat Mini Programs. Generally speaking, it is not too difficult to get in touch with him for the first time.
I feel a lot about the looping problem of Mini Program, because I use loops and nested loops countless times to bind data to the interface.
For the data we get from the interface in js through POST or GET request, we store it in the object defined in Page:
/ / Home topic list wx.request ({url: 'https://*******************', method:' POST', data: {pageNum: 1, pageSize: 10}, success:function (res) {that.setData ({listTop:res.data,})})
In the wxml file through the
Wx:for= "{{listTop}}"
To loop out the data in the object. Here we can obtain the subscript through {{index}}, or customize the subscript:
Wx:for-index= "index2"
When there is an object com in listTop, we can loop the data in the loop through wx:for= "{{item.com}}".
In the actual project, I encountered such a problem: in the process of nesting loop, I need to convert the value of a field, such as a timestamp to a date / a few days ago, etc., at this time we should
Knowing that WeChat Mini Programs does not support calling JS directly from the interface, what should we do at this time:
At first, I made a big mistake. I always wanted to put it into an object through a loop in JS, and then loop it out in the interface. In fact, I was close to the result in the previous step, but in actual development
As a novice who has just started for less than a month, I still have a lot of shortcomings, so I fall into an endless cycle.
Solution: when you traverse it, just replace the original data with the data you want. (it's simple, but it's a mystery, but because you solve it yourself, it may exist.
A better way, which is only described here)
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) ) {res.data.data.comments.createTime = transDate (res.data.data [I] .comments.createTime)} this is the end of this article, "how to achieve loops and nested loops by WeChat Mini Programs". If you want to master the knowledge points of this article, you still need to practice and use it. If you want to know more about related articles, Welcome to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.