In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "WeChat Mini Programs cycle and the method of nested loop". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the method of WeChat Mini Programs loop and nested loop.
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) CreateTime = transDate (res.data.data [I] .createTime = res.data.data [I] .comments.createTime)} so far, I believe you have a deeper understanding of "WeChat Mini Programs loop and the method of nested loop". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.