From aeac8bb42246c9f106e87d2e584d13f14ee12279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=9B=E4=BA=9A=E8=8A=B3?= Date: Wed, 4 Jan 2023 12:20:15 +0000 Subject: [PATCH] update zh-cn/application-dev/reference/apis/js-apis-system-storage.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 葛亚芳 --- .../reference/apis/js-apis-system-storage.md | 107 +++++++++++------- 1 file changed, 69 insertions(+), 38 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-storage.md b/zh-cn/application-dev/reference/apis/js-apis-system-storage.md index cbe6e36b02..d35b15d1ff 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-storage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-storage.md @@ -2,22 +2,21 @@ > **说明:** > -> - 从API Version 6开始,该模块不再维护,可以使用模块[`@ohos.data.storage`](js-apis-data-storage.md)。在API Version 9后,推荐使用新模块[`@ohos.data.preferences`](js-apis-data-preferences.md)。 +> - 从API Version 6开始,该模块不再维护,可以使用模块[`@ohos.data.storage`](js-apis-data-storage.md)。在API Version 9后,推荐使用新模块[`@ohos.data.preferences`](js-apis-data-preferences.md)。 > -> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> - 本模块接口仅可在FA模型下使用。 +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> - 本模块接口仅可在FA模型下使用。 ## 导入模块 - ```js import storage from '@system.storage'; ``` - ## storage.get -get(Object): void +get(options: GetStorageOptions): void 通过索引读取缓存中存储的值。 @@ -25,13 +24,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 +49,9 @@ export default { } ``` - ## storage.set -set(Object): void +get(options: SetStorageOptions): void 修改缓存中索引对应的值。 @@ -65,13 +59,9 @@ set(Object): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| key | string | 是 | 要修改的存储值的索引。 | -| value | string | 是 | 新值。长度需小于128字节。 | -| success | Function | 否 | 接口调用成功的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数,data为错误信息,code为错误码。 | -| complete | Function | 否 | 接口调用结束的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------- | ---- | ---------- | +| options | [SetStorageOptions](#setstorageoptions) | 是 | 接口配置信息。 | **示例:** @@ -92,10 +82,9 @@ export default { } ``` - ## storage.clear -clear(Object): void +clear(options?: ClearStorageOptions): void 清空缓存中存储的键值对。 @@ -103,11 +92,9 @@ clear(Object): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| success | Function | 否 | 接口调用成功的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数,data为错误信息,code为错误码。 | -| complete | Function | 否 | 接口调用结束的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------------------- | ---- | -------------- | +| options | [ClearStorageOptions](#clearstorageoptions) | 否 | 接口配置信息。 | **示例:** @@ -126,10 +113,9 @@ export default { } ``` - ## storage.delete -delete(Object): void +delete(options: DeleteStorageOptions): void 删除缓存中索引对应的键值对。 @@ -137,12 +123,9 @@ delete(Object): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| key | string | 是 | 内容索引。 | -| success | Function | 否 | 接口调用成功的回调函数。 | -| fail | Function | 否 | 接口调用失败的回调函数,data为错误信息,code为错误码。 | -| complete | Function | 否 | 接口调用结束的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------------------------- | ---- | -------------- | +| options | [DeleteStorageOptions](#deletestorageoptions) | 是 | 接口配置信息。 | **示例:** @@ -160,4 +143,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 -- GitLab