Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lfmiao0
Docs
提交
1e1dd817
D
Docs
项目概览
lfmiao0
/
Docs
与 Fork 源项目一致
Fork自
OpenHarmony / Docs
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
1e1dd817
编写于
1月 04, 2023
作者:
葛
葛亚芳
提交者:
Gitee
1月 04, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/application-dev/reference/apis/js-apis-system-storage.md.
Signed-off-by:
N
葛亚芳
<
geyafang@huawei.com
>
上级
a41584dd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
67 addition
and
38 deletion
+67
-38
zh-cn/application-dev/reference/apis/js-apis-system-storage.md
.../application-dev/reference/apis/js-apis-system-storage.md
+67
-38
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-system-storage.md
浏览文件 @
1e1dd817
...
...
@@ -2,22 +2,19 @@
> **说明:**
>
> - 从API Version 6开始,该模块不再维护,可以使用模块[`@ohos.data.storage`](js-apis-data-storage.md)。
>
- 从API Version 6开始,该模块不再维护,可以使用模块[`@ohos.data.storage`](js-apis-data-storage.md)。
>
> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
js
import
storage
from
'
@system.storage
'
;
```
## storage.get
get(
Object
): void
get(
options: GetStorageOptions
): void
通过索引读取缓存中存储的值。
...
...
@@ -25,13 +22,9 @@ get(Object): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| key | string | 是 | 内容索引。 |
| default | string | 否 | key不存在则返回的默认值。 |
| success | Function | 否 | 接口调用成功的回调函数,data为返回key对应的value。 |
| fail | Function | 否 | 接口调用失败的回调函数,data为错误信息,code为错误码。 |
| complete | Function | 否 | 接口调用结束的回调函数。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | -------------------- | ---- | ---------- |
| options |
[
GetStorageOptions
](
#getstorageoptions
)
| 是 | 接口配置信息。 |
**示例:**
...
...
@@ -54,10 +47,9 @@ export default {
}
```
## storage.set
set(Object
): void
get(options: SetStorageOptions
): void
修改缓存中索引对应的值。
...
...
@@ -65,13 +57,9 @@ set(Object): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| key | string | 是 | 要修改的存储值的索引。 |
| value | string | 是 | 新值。长度需小于128字节。 |
| success | Function | 否 | 接口调用成功的回调函数。 |
| fail | Function | 否 | 接口调用失败的回调函数,data为错误信息,code为错误码。 |
| complete | Function | 否 | 接口调用结束的回调函数。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ---------- |
| options |
[
SetStorageOptions
](
#setstorageoptions
)
| 是 | 接口配置信息。 |
**示例:**
...
...
@@ -92,10 +80,9 @@ export default {
}
```
## storage.clear
clear(
Object
): void
clear(
options?: ClearStorageOptions
): void
清空缓存中存储的键值对。
...
...
@@ -103,11 +90,9 @@ clear(Object): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| success | Function | 否 | 接口调用成功的回调函数。 |
| fail | Function | 否 | 接口调用失败的回调函数,data为错误信息,code为错误码。 |
| complete | Function | 否 | 接口调用结束的回调函数。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------------------- | ---- | -------------- |
| options |
[
ClearStorageOptions
](
#clearstorageoptions
)
| 否 | 接口配置信息。 |
**示例:**
...
...
@@ -126,10 +111,9 @@ export default {
}
```
## storage.delete
delete(
Object
): void
delete(
options: DeleteStorageOptions
): void
删除缓存中索引对应的键值对。
...
...
@@ -137,12 +121,9 @@ delete(Object): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| key | string | 是 | 内容索引。 |
| success | Function | 否 | 接口调用成功的回调函数。 |
| fail | Function | 否 | 接口调用失败的回调函数,data为错误信息,code为错误码。 |
| complete | Function | 否 | 接口调用结束的回调函数。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | --------------------------------------------- | ---- | -------------- |
| options |
[
DeleteStorageOptions
](
#deletestorageoptions
)
| 是 | 接口配置信息。 |
**示例:**
...
...
@@ -160,4 +141,52 @@ export default {
});
}
}
```
\ No newline at end of file
```
## GetStorageOptions
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
| 名称 | 类型 | 必填 | 说明 |
| -------- | ---------------- | ---- | ------------------- |
| key | string | 是 | 内容索引。 |
| default | string | 否 | key不存在则返回的默认值。 |
| success | (data: any) => void | 否 | 接口调用成功的回调函数,data为返回key对应的value。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数,data为错误信息,code为错误码。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
## SetStorageOptions
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
| 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------- | ---- | -------------------- |
| key | string | 是 | 要修改的存储值的索引。 |
| value | string | 是 | 新值。长度需小于128字节。 |
| success | () => void | 否 | 接口调用成功的回调函数。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数,data为错误信息,code为错误码。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
## ClearStorageOptions
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
| 名称 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- |
| success | () => void | 否 | 接口调用成功的回调函数。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数,data为错误信息,code为错误码。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
## DeleteStorageOptions
**系统能力:**
SystemCapability.DistributedDataManager.Preferences.Core
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------ |
| key | string | 是 | 内容索引。 |
| success | () => void | 否 | 接口调用成功的回调函数。 |
| fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数,data为错误信息,code为错误码。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录