# wx.setStorage(Object object)

with Promise style call: Supported

Mini Program plugin: Support, need to Mini Program base library version no less than 1.9.6

To store data in the local cache key In. Will overwrite the original key The corresponding content. Data is always available unless the user actively deletes it or the system cleans it for storage reasons. single key The maximum length of data allowed to be stored is 1 MB, all data storage capped at 10MB。

# parameter

# Object object

attribute type Default values Required Introductions
key string yes Specified in the local cache key
data any yes The content that needs to be stored. Supports only native types, Date, and the ability to passJSON.stringifySerialized object.
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)

# sample code

try {
  wx.setStorageSync('key', 'value')
} catch (and) { }