设置缓存


接口说明

缓存只能存入字符串的内容,暂不支持音频、图片等资源。

HWH5.setStorage

  • 基础库从 10.0.5 开始支持,低版本需做兼容处理
  • cache在后续版本中将会逐渐废弃,请使用setStorage代替

请求参数

参数 类型 必填 说明
key String 存、取缓存数据的key
data Object 要存入的值

返回结果

无。

请求示例

  • ES6版本

    HWH5.setStorage({
      key: 'bulletin_detail_c00299309_10010',
      data: '{data:"WeLink is platform"}'
    }).catch(error => {
      console.log('设置缓存异常', error);
    });
    
  • ES5版本

    HWH5.setStorage({
      key: 'bulletin_detail_c00299309_10010',
      data: '{data:"WeLink is platform"}'
    }).catch(function (error) {
      console.log('设置缓存异常', error);
    });
    

result. ""

    Not Found. ""