WeChat Mini Program: New data management API
wx.getStorage(OBJECT)
Asynchronously obtain the content corresponding to the specified key from the local cache.
OBJECT parameter description:
[tr]Parameter type required description[/tr]
key | String | is the specified key in the | local cache |
success | Function | It is the callback function called by the | interface, res = {data: the content corresponding to key} |
Function | No | Callback function for interface call failure | |
Function | No | Callback function for end of interface call Function (executed successfully or failed) |
Sample code:
wx.getStorage({ key: 'key', success: function(res) { console.log(res.data) } }) wx.getStorageSync(KEY)
Parameter description: [tr]Parameter type required description[/tr]
String | is the specified key in the | local cache |
try { var value = wx.getStorageSync('key') if (value) { // Do something with return value } } catch(e) { // Do something when catch error } wx.getStorageInfo(OBJECT)
Asynchronously obtain relevant information about the current storage
OBJECT parameter description:
[tr]Parameter type required description[/tr]
Function | is the callback function called by the | interface. For details, please see the return parameter description | |
Function | No | Callback function for failed interface call | |
Function | No | The callback function at the end of the interface call (will be executed if the call is successful or failed) |
[tr]Parameter type description[/tr]
String Array | In current storage All keys | |
Number | The size of the space currently occupied, unit kb | |
Number | Limited space size, unit kb |
wx.getStorageInfo({
success: function(res) {
console.log(res.keys);
console.log(res.currentSize);
console.log(res.limitSize);
}
})###wx.getStorageInfoSync同步获取当前storage的相关信息 * *示例代码: * *"javascript
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(OBJECT)
OBJECT parameter description:
[tr]Parameter type required description[/tr]
String | is the specified key in the | local cache | |
Function | Yes | The callback function called by the interface | |
Function | No | The callback function called by the interface fails Function | |
Function | No | The callback function at the end of the interface call (will be executed if the call is successful or failed) |
wx.removeStorage({ key: 'key', success: function(res) { console.log(res.data) } }) wx.removeStorageSync(KEY)
Synchronously remove the specified key from the local cache.
Parameter description:
[tr]Parameter type required description[/tr]
String | is the specified key in the | local cache |
try {
wx.removeStorageSync('key')
} catch(e) {
// Do something when catch error
}
For more WeChat mini programs: New data management API, please pay attention to the PHP Chinese website for related articles!

Hot AI Tools

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

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

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

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)
