HWH5.setStorage
HWH5.getStorage
HWH5.clearStorage
HWH5.removeStorage
HWH5.setStorage
设置缓存,暂不支持音频、图片等资源
扫码体验:
请求参数
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
key | String | 是 | 存、取缓存数据的key |
data | Object | 是 | 要存入的值 |
isolation | Number | 否 | 跨租户时应用的数据是否需要隔离,1 隔离, 0 不隔离,不传默认不隔离 |
注意:data数据最大存储限制为128KB。
返回结果
无。
请求示例
ES6版本
HWH5.setStorage({ key: 'bulletin_detail_c00299309_10010', data: '{data:"WeLink is platform"}', isolation: 1 }).catch(error => { console.log('设置缓存异常', error); });
ES5版本
HWH5.setStorage({ key: 'bulletin_detail_c00299309_10010', data: '{data:"WeLink is platform"}', isolation: 1 }).catch(function (error) { console.log('设置缓存异常', error); });
HWH5.getStorage
获取指定key值的缓存
扫码体验:
请求参数
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
key | String | 是 | 存、取缓存数据的key |
isolation | Number | 否 | 跨租户时应用的数据是否需要隔离,1 隔离, 0 不隔离,不传默认不隔离 |
返回结果
参数 | 说明 |
---|---|
data | 缓存的数据 |
请求示例
ES6版本
HWH5.getStorage({ key: 'bulletin_detail_c00299309_10010', isolation: 1 }) .then(data => { console.log(data); }) .catch(error => { console.log('获取缓存异常', error); });
ES5版本
HWH5.getStorage({ key: 'bulletin_detail_c00299309_10010', isolation: 1 }) .then(function (data) { console.log(data); }) .catch(function (error) { console.log('获取缓存异常', error); });
HWH5.clearStorage
清理缓存将会清理当前We码小程序所有的缓存记录
扫码体验:
请求参数
无。
返回结果
参数 | 说明 |
---|---|
data | 成功:success,失败:error |
请求示例
ES6版本
HWH5.clearStorage().then(data => { console.log(data); }).catch(error => { console.log('清理本地H5缓存', error); });
ES5版本
HWH5.clearStorage().then(function (data) { console.log(data); }).catch(function (error) { console.log('清理本地H5缓存', error); });
HWH5.removeStorage
删除缓存将会删除当前We码小程序指定key值的缓存记录
扫码体验:
请求参数
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
key | String | 是 | 删除的缓存 |
返回结果
参数 | 说明 |
---|---|
status | 成功:1 |
请求示例
ES6版本
HWH5.removeStorage({ key: 'onepice', isolation: 1 }).then(data => { console.log(data); }).catch(error => { console.log('删除缓存失败', error); });
ES5版本
HWH5.removeStorage({ key: 'onepice', isolation: 1 }').then(function (data) { console.log(data); }).catch(function (error) { console.log('删除缓存失败', error); });