---
name: "getStorageSync"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.0.1" }
platform:
  - "iOS"
  - "Android"
title: "getStorageSync - 从本地缓存中异步获取指定 key 的内容的同步版本"
---

## getStorageSync

> [VERSION] BaseKit >= 2.0.1

> [PLATFORM] iOS, Android

### 描述

从本地缓存中异步获取指定 key 的内容

### 参数

`Params`

| 参数 | 类型 | 必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| `storageKeyBean` | `StorageKeyBean` | 否 | - | 参数对象 |

### 引用对象

##### `interface` StorageKeyBean

| 属性 | 类型 | 最低版本 | 描述 |
| --- | --- | --- | --- |
| `key` | `string` | `2.0.1` | 本地缓存中指定的 key |


### 示例代码

```tsx
// 获取本地缓存指定 key 的内容：先写后读，演示完整往返
ty.setStorage({
  key: "demoKey",
  data: "demoValue",
  success: () => {
    ty.getStorage({
      key: "demoKey",
      success: data => console.log("读取内容：", data),
      fail: error => console.error(error),
    });
  },
  fail: error => console.error(error),
});
```
