diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md b/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md index 813277d8d46ad7f24e20b6e87a5abf3eda0c41ce..ebf5e3263cbe4ba170ec5b789a6c5ce40b6235d6 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md @@ -14,7 +14,8 @@ ## 导入模块 ```ts -import systemparameter from '@ohos.systemparameter' +import systemparameter from '@ohos.systemparameter'; +import { BusinessError } from '@ohos.base'; ``` ## systemparameter.getSync(deprecated) @@ -42,7 +43,7 @@ getSync(key: string, def?: string): string ```ts try { - var info = systemparameter.getSync("const.ohos.apiversion"); + let info = systemparameter.getSync("const.ohos.apiversion"); console.log(JSON.stringify(info)); } catch(e) { console.log("getSync unexpected error: " + e); @@ -68,7 +69,7 @@ get(key: string, callback: AsyncCallback<string>): void ```ts try { - systemparameter.get("const.ohos.apiversion", function (err, data) { + systemparameter.get("const.ohos.apiversion", (err:BusinessError, data:string) => { if (err == undefined) { console.log("get test.parameter.key value success:" + data) } else { @@ -99,7 +100,7 @@ get(key: string, def: string, callback: AsyncCallback<string>): void ```ts try { - systemparameter.get("const.ohos.apiversion", "default", function (err, data) { + systemparameter.get("const.ohos.apiversion", "default", (err:BusinessError, data:string) => { if (err == undefined) { console.log("get test.parameter.key value success:" + data) } else { @@ -136,10 +137,10 @@ get(key: string, def?: string): Promise<string> ```ts try { - var p = systemparameter.get("const.ohos.apiversion"); - p.then(function (value) { + let p = systemparameter.get("const.ohos.apiversion"); + p.then((value:string) => { console.log("get test.parameter.key success: " + value); - }).catch(function (err) { + }).catch((err:BusinessError) => { console.log("get test.parameter.key error: " + err.code); }); } catch(e) { @@ -201,7 +202,7 @@ set(key: string, value: string, callback: AsyncCallback<void>): void ```ts try { - systemparameter.set("test.parameter.key", "testValue", function (err, data) { + systemparameter.set("test.parameter.key", "testValue", (err:BusinessError, data:string) =>{ if (err == undefined) { console.log("set test.parameter.key value success :" + data) } else { @@ -241,10 +242,10 @@ set(key: string, value: string): Promise<void> ```ts try { - var p = systemparameter.set("test.parameter.key", "testValue"); - p.then(function (value) { + let p = systemparameter.set("test.parameter.key", "testValue"); + p.then((value:string) => { console.log("set test.parameter.key success: " + value); - }).catch(function (err) { + }).catch((err:BusinessError) => { console.log(" set test.parameter.key error: " + err.code); }); } catch(e) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-parameterEnhance.md b/zh-cn/application-dev/reference/apis/js-apis-system-parameterEnhance.md index deb3aa478fd82c340b70cc088dda988e38ef1075..446d10c87d594a47bee6db382ac098d0ce46ac86 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-system-parameterEnhance.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-parameterEnhance.md @@ -13,7 +13,8 @@ ## 导入模块 ```ts -import systemparameter from '@ohos.systemParameterEnhance' +import systemparameter from '@ohos.systemParameterEnhance'; +import { BusinessError } from '@ohos.base'; ``` ## systemparameter.getSync @@ -41,7 +42,7 @@ getSync(key: string, def?: string): string ```ts try { - var info = systemparameter.getSync("const.ohos.apiversion"); + let info = systemparameter.getSync("const.ohos.apiversion"); console.log(JSON.stringify(info)); } catch(e) { console.log("getSync unexpected error: " + e); @@ -67,7 +68,7 @@ get(key: string, callback: AsyncCallback<string>): void ```ts try { - systemparameter.get("const.ohos.apiversion", function (err, data) { + systemparameter.get("const.ohos.apiversion", (err:BusinessError, data:string) => { if (err == undefined) { console.log("get test.parameter.key value success:" + data) } else { @@ -98,7 +99,7 @@ get(key: string, def: string, callback: AsyncCallback<string>): void ```ts try { - systemparameter.get("const.ohos.apiversion", "default", function (err, data) { + systemparameter.get("const.ohos.apiversion", "default", (err:BusinessError, data:string) => { if (err == undefined) { console.log("get test.parameter.key value success:" + data) } else { @@ -135,10 +136,10 @@ get(key: string, def?: string): Promise<string> ```ts try { - var p = systemparameter.get("const.ohos.apiversion"); - p.then(function (value) { + let p = systemparameter.get("const.ohos.apiversion"); + p.then((value:string) => { console.log("get test.parameter.key success: " + value); - }).catch(function (err) { + }).catch((err:BusinessError) => { console.log("get test.parameter.key error: " + err.code); }); } catch(e) { @@ -191,7 +192,7 @@ set(key: string, value: string, callback: AsyncCallback<void>): void ```ts try { - systemparameter.set("test.parameter.key", "testValue", function (err, data) { + systemparameter.set("test.parameter.key", "testValue", (err:BusinessError, data:string) => { if (err == undefined) { console.log("set test.parameter.key value success :" + data) } else { @@ -227,10 +228,10 @@ set(key: string, value: string): Promise<void> ```ts try { - var p = systemparameter.set("test.parameter.key", "testValue"); - p.then(function (value) { + let p = systemparameter.set("test.parameter.key", "testValue"); + p.then((value:string) => { console.log("set test.parameter.key success: " + value); - }).catch(function (err) { + }).catch((err:BusinessError) => { console.log(" set test.parameter.key error: " + err.code); }); } catch(e) {