Home WeChat Applet Mini Program Development WeChat Mini Program: New data management API

WeChat Mini Program: New data management API

May 15, 2018 pm 01:53 PM

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]

##failFunctionNo Callback function for interface call failurecompleteFunctionNoCallback function for end of interface call Function (executed successfully or failed)
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}

Sample code:

wx.getStorage({
    key: 'key',
    success: function(res) {
        console.log(res.data)
    }
}) wx.getStorageSync(KEY)
Copy after login

Synchronously obtain the specified specification from the local cache The content corresponding to key.


Parameter description: [tr]Parameter type required description[/tr]

keyString is the specified key in the local cache
##Sample code:

try {
    var value = wx.getStorageSync('key') if (value) {
        // Do something with return value
    }
} catch(e) {
    // Do something when catch error
}
wx.getStorageInfo(OBJECT)
Copy after login

Asynchronously obtain relevant information about the current storage

OBJECT parameter description:
[tr]Parameter type required description[/tr]

successfailcomplete
Function is the callback function called by the interface. For details, please see the return parameter description
FunctionNoCallback function for failed interface call
FunctionNoThe callback function at the end of the interface call (will be executed if the call is successful or failed)
success return parameter description :

[tr]Parameter type description[/tr]

keyscurrentSizelimitSize
String ArrayIn current storage All keys
NumberThe size of the space currently occupied, unit kb
NumberLimited space size, unit kb
Sample code:

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)
Copy after login

Asynchronously remove the specified key from the local cache.

OBJECT parameter description:
[tr]Parameter type required description[/tr]

keysuccessfailcomplete
String is the specified key in the local cache
Function YesThe callback function called by the interface
FunctionNoThe callback function called by the interface fails Function
FunctionNoThe callback function at the end of the interface call (will be executed if the call is successful or failed)
Sample code:

wx.removeStorage({
    key: 'key',
    success: function(res) {
        console.log(res.data)
    }
}) wx.removeStorageSync(KEY)
Copy after login

Synchronously remove the specified key from the local cache.

Parameter description:
[tr]Parameter type required description[/tr]

key
String is the specified key in the local cache
Sample code:

try {
    wx.removeStorageSync('key')
} catch(e) {
    // Do something when catch error
}
Copy after login

For more WeChat mini programs: New data management API, please pay attention to the PHP Chinese website for related articles!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)