taro 本地存储Storage
1、存储同步Taro.setStorageSync('key',存储数据)异步Taro.setStorage({key:"xx",data:存储数据})2、读取同步Taro.getStorageSync('key')异步Taro.getStorage({key: 'key',success: function (res) {res.data}})3、删除同步
·
1、存储
同步
Taro.setStorageSync('key',存储数据)
异步
Taro.setStorage({
key:"xx",
data:存储数据
})
2、读取
同步
Taro.getStorageSync('key')
异步
Taro.getStorage({
key: 'key',
success: function (res) {
res.data
}
})
3、删除
同步
Taro.removeStorageSync('key')
异步
Taro.removeStorage({
key: 'key',
success: function (res) {
res.data
}
})
4、获取本地存储信息
同步
const res = Taro.getStorageInfoSync()
res.currentSize 当前占用的空间大小, 单位 KB
res.keys 当前 storage 中所有的 key
res.limitSize 限制的空间大小,单位 KB
异步
Taro.getStorageInfo({
success: function (res) {
res.keys
res.currentSize
res.limitSize
}
})
5、清空存储
同步
Taro.clearStorageSync()
异步
Taro.clearStorage()
更多推荐
所有评论(0)