In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how to cache data in WeChat Mini Programs". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to cache data in WeChat Mini Programs" can help you solve the problem.
WeChat Mini Programs can set, get and clean the local cache through wx.setStorage (wx.setStorageSync), wx.getStorage (wx.getStorageSync) and wx.clearStorage (wx.clearStorageSync). The maximum local cache is 10MB.
Wx.setStorage ()-set cache asynchronously
Official attributes given by Wechat
OBJECT parameter description:
Parameter type required indicates that keyString is the specified keydataObject/String in the local cache. SuccessFunction No API calls successful callback function failFunction No API calls failed callback function completeFunction No API call ends callback function (both successful and failed calls will be executed)
Call method:
Wx.setStorage ({key: "key", data: "value"})
Wx.setStorageSync ()-synchronizes the settings cache
Official attributes given by Wechat
Parameter description:
The parameter type is required to indicate that keyString is the specified keydataObject/String in the local cache and the content to be stored
Call method:
Try {wx.setStorageSync ('key',' value')} catch (e) {}
Wx.getStorage ()-get cache asynchronously
Official attributes given by Wechat
OBJECT parameter description:
The parameter type is required to indicate that keyString is the specified keysuccessFunction in the local cache. Res = {data: key corresponding to content} failFunction No API call failed callback function completeFunction No API call end callback function (both successful and failed calls will be executed)
Success return parameter description:
Parameter type describes the content corresponding to dataStringkey
Call method:
Wx.getStorage ({key: 'key', success: function (res) {console.log (res.data)}})
Wx.getStorageSync ()-get cached data synchronously
The official attribute description given by Wechat
Parameter description:
Parameter type is required indicating that keyString is the specified key in the local cache
Call method:
Try {var value = wx.getStorageSync ('key') if (value) {/ / Do something with return value}} catch (e) {/ / Do something when catch error}
Wx.getStorageInfo ()-get the currently cached data asynchronously
The official attribute description given by Wechat
OBJECT parameter description:
The parameter type is required to indicate that successFunction is the callback function called by the API. For more information, please see the returned parameters indicating whether the API failed callback function failFunction. CompleteFunction No callback function at the end of API call (both successful and failed calls will be executed)
Success return parameter description:
The parameter type indicates the amount of space currently occupied by all keycurrentSizeNumber in keysString Array's current storage, the space limited by unit kblimitSizeNumber, and the unit kb.
Call method:
Wx.getStorageInfo ({success: function (res) {console.log (res.keys) console.log (res.currentSize) console.log (res.limitSize)})
Wx.getStorageInfoSync ()-get the current cache data synchronously
Emmmmm--- Wechat did not specify the parameters.
Call method:
Try {var res = wx.getStorageInfoSync () console.log (res.keys) console.log (res.currentSize) console.log (res.limitSize)} catch (e) {/ / Do something when catch error}
Wx.removeStorage ()-asynchronously removes cached data from the specified key
Description of official parameters of Wechat
OBJECT parameter description:
Parameter type required indicates that keyString is specified in the local cache. KeysuccessFunction is the callback function called by the API failFunction No callback function failed by API call completeFunction No callback function at the end of API call (both successful and failed calls will be executed)
Call method:
Wx.removeStorage ({key: 'key', success: function (res) {console.log (res.data)}})
Wx.removeStorageSync ()-removes cached data from the specified key synchronously
Description of official parameters of Wechat
Parameter description:
Parameter type is required indicating that keyString is the specified key in the local cache
Call method:
Try {wx.removeStorageSync ('key')} catch (e) {/ / Do something when catch error}
Wx.clearStorage ()-asynchronously cleans up the local cache
Call method:
Wx.clearStorage ()
Wx.clearStorageSync ()-synchronously cleans the local cache
Call method:
Try {wx.clearStorageSync ()} catch (e) {/ / Do something when catch error} about "how to cache data in WeChat Mini Programs", thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.