# Function: setStorage
▸ setStorage‹T›(params
: SetStorageParams‹T›): Promise‹SetStorageRes›
将数据存储在本地缓存中指定的 key 中。 会覆盖掉原来该 key 对应的内容。 除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。 单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。
# Type parameters:
▪ T
# 参数:
属性 | 类型 |
---|---|
params | SetStorageParams‹T› |
SetStorageParams
属性 | 类型 | 描述 |
---|---|---|
data | T | 需要存储的内容。 只支持原生类型、Date、及能够通过JSON.stringify序列化的对象。 |
key | string | 本地缓存中指定的 key |
complete? | Method | 接口调用结束的回调函数(调用成功、失败都会执行) |
fail? | Method | 接口调用失败的回调函数 |
success? | Method | 接口调用成功的回调函数 |
# 返回值:
Promise‹SetStorageRes›