Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does WeChat Mini Programs realize up-sliding, loading, pulling and refreshing

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to realize the up-slide, load-down and refresh of WeChat Mini Programs". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn how WeChat Mini Programs can achieve up-slide, load-drop and refresh.

The setting of the page cache optimizes the page loading, reduces the frequent call interface, and makes the user have a better experience when the network is off.

Each WeChat Mini Programs can have its own local cache, which can be set, acquired and cleaned through wx.setStorage (wx.setStorageSync), wx.getStorage (wx.getStorageSync) and wx.clearStorage (wx.clearStorageSync). The maximum local cache is 10MB.

Note: localStorage is permanently stored, but we do not recommend storing all critical information in localStorage in case users change devices.

Project requirements

Listen for page drop-down events by using the mouse scroll event onscrollLower customized by scroll-view

The API for requesting data is encapsulated in the method of page.init (). The background api document has its own paging pageSize. The default value is 10, which requests all data.

Description:

Trigger the slide event to request the interface by comparing with the page data cache data.

Code implementation

Var page.init = function (callback) {page.data.loading = true; naughty 10; cardService.listFavoriteCards (var cards = result.data.favoriteCards; var starCards = result.data.starCards; starCards.sort (function (C1 ~ c2) {var c1Name = pinyingUtil.getInitials.convertPinyin (c1.name); var c2Name = pinyingUtil.getInitials.convertPinyin (c2.name); return c1Name > c2Name? 1:-1;}) If (starCards & & starCards.length > 0) {starCards.forEach (function (c) {var compressEntName = dictService.compressEntName (c.companyName); c.compressEntName = compressEntName;});} page.setData ({"favoriteCards": cards, "starCards": starCards, "filterType": "name", "groups": cardService.groupCardsByNameFirstLetter (cards), "loadding": false}); wx.setStorageSync ("setgroups", page.data.groups)});} } onLoad: function (options) {var geigroups=wx.getStorageSync ('setgroups') var result = [] for (var item0; I

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report