# wx.getStorage(Object object)
with Promise style call: Supported
Mini Program plugin: Support, need to Mini Program base library version no less than 1.9.6
Gets the specified object asynchronously from the local cache key The content of. Cache related policies to view storage。
# parameter
# Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
key | string | yes | Specified in the local cache key | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
# object.success callback
# parameter
# Object res
attribute | type | Introductions |
---|---|---|
data | any | Key corresponds to the content |
# sample code
wx.getStorage({
key: 'key',
success (res) {
console.log(res.data)
}
})
try {
where value = wx.getStorageSync('key')
if (value) {
// From the something with return value
}
} catch (and) {
// From the something when catch error
}