swan.getStorageInfo

解释:异步获取当前 storage 的相关信息。

方法参数

Object object

object 参数说明

属性名类型必填默认值说明

success

Function

接口调用成功的回调函数,详见返回参数说明

fail

Function

接口调用失败的回调函数

complete

Function

接口调用结束的回调函数(调用成功、失败都会执行)

success 返回参数说明

参数类型说明

keys

Array.<string>

当前 storage 中所有的 key

currentSize

Number

当前占用的空间大小(单位:KB)

limitSize

Number

限制的空间大小(单位:KB)

示例

跳转编辑工具

在开发者工具中打开

在 WEB IDE 中打开

扫码体验

代码示例

百度智能小程序

请使用百度APP扫码

图片示例

swan.getStorageInfo - 图2

代码示例

  • SWAN
  • JS
  1. <view class="wrap">
  2. <view class="card-area">
  3. <view class="list-area border-bottom">
  4. <label class="list-item-key-4">key</label>
  5. <input class="list-item-value" bindfocus="keyFocus" bindinput="keyInput" type="text" value="{{key}}" placeholder="请输入key" />
  6. </view>
  7. <view class="list-area border-bottom">
  8. <label class="list-item-key-4">value</label>
  9. <input class="list-item-value" bindfocus="valueFocus" bindinput="valueInput" type="text" value="{{value}}" placeholder="请输入value" />
  10. </view>
  11. <view>
  12. <button bindtap="setStorage" type="primary" hover-stop-propagation="true">存储数据</button>
  13. <button bindtap="getStorage" type="primary" hover-stop-propagation="true" disabled="{{disabled}}">读取数据</button>
  14. <button bindtap="getStorageInfoSync" type="primary" disabled="{{disabled}}">获取存储数据信息</button>
  15. </view>
  16. </view>
  17. </view>

错误码

Android

错误码说明

1001

执行失败