提交 6f2fabf5 编写于 作者: C chengjinsong2

修改napi文档

Signed-off-by: Nchengjinsong2 <chengjinsong2@huawei.com>
上级 ec800639
...@@ -30,13 +30,13 @@ getSync(key: string, def?: string): string ...@@ -30,13 +30,13 @@ getSync(key: string, def?: string): string
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | 是 | 待查询的系统参数Key。 | | key | string | 是 | 待查询的系统参数Key。 |
| def | string | 否 | def 为所要获取的系统参数的默认值 <br> def为可选参数,仅当系统参数不存在时生效 <br>def可以传undefined(返回空)或自定义的任意值 | | def | string | 否 | def为所要获取的系统参数的默认值 <br> def为可选参数,仅当系统参数不存在时生效 <br>def可以传undefined或自定义的任意值 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| string | 系统参数值,若key不存在,返回默认值。若未指定默认值,返回空字符串。 | | string | 系统参数值<br> 若key存在,返回设定的值。<br> 若key不存在且def有效,返回def;若未指定def或def无效(如undefined),返回空字符串。 |
**示例:** **示例:**
...@@ -44,7 +44,7 @@ getSync(key: string, def?: string): string ...@@ -44,7 +44,7 @@ getSync(key: string, def?: string): string
try { try {
var info = systemparameter.getSync("const.ohos.apiversion"); var info = systemparameter.getSync("const.ohos.apiversion");
console.log(JSON.stringify(info)); console.log(JSON.stringify(info));
}catch(e){ } catch(e) {
console.log("getSync unexpected error: " + e); console.log("getSync unexpected error: " + e);
} }
``` ```
...@@ -74,7 +74,7 @@ try { ...@@ -74,7 +74,7 @@ try {
} else { } else {
console.log(" get test.parameter.key value err:" + err.code) console.log(" get test.parameter.key value err:" + err.code)
}}); }});
}catch(e){ } catch(e) {
console.log("get unexpected error: " + e); console.log("get unexpected error: " + e);
} }
``` ```
...@@ -106,7 +106,7 @@ try { ...@@ -106,7 +106,7 @@ try {
console.log(" get test.parameter.key value err:" + err.code) console.log(" get test.parameter.key value err:" + err.code)
} }
}); });
}catch(e){ } catch(e) {
console.log("get unexpected error:" + e) console.log("get unexpected error:" + e)
} }
``` ```
...@@ -124,7 +124,7 @@ get(key: string, def?: string): Promise&lt;string&gt; ...@@ -124,7 +124,7 @@ get(key: string, def?: string): Promise&lt;string&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | 是 | 待查询的系统参数Key。 | | key | string | 是 | 待查询的系统参数Key。 |
| def | string | 否 | def 为所要获取的系统参数的默认值 <br> def为可选参数,仅当系统参数不存在时生效 <br>def可以传undefined(返回空)或自定义的任意值 | | def | string | 否 | def为所要获取的系统参数的默认值 <br> def为可选参数,仅当系统参数不存在时生效 <br> def可以传undefined或自定义的任意值 |
**返回值:** **返回值:**
...@@ -142,7 +142,7 @@ try { ...@@ -142,7 +142,7 @@ try {
}).catch(function (err) { }).catch(function (err) {
console.log("get test.parameter.key error: " + err.code); console.log("get test.parameter.key error: " + err.code);
}); });
}catch(e){ } catch(e) {
console.log("get unexpected error: " + e); console.log("get unexpected error: " + e);
} }
``` ```
...@@ -172,7 +172,7 @@ setSync(key: string, value: string): void ...@@ -172,7 +172,7 @@ setSync(key: string, value: string): void
```ts ```ts
try { try {
systemparameter.setSync("test.parameter.key", "default"); systemparameter.setSync("test.parameter.key", "default");
}catch(e){ } catch(e) {
console.log("set unexpected error: " + e); console.log("set unexpected error: " + e);
} }
``` ```
...@@ -207,7 +207,7 @@ try { ...@@ -207,7 +207,7 @@ try {
} else { } else {
console.log("set test.parameter.key value err:" + err.code) console.log("set test.parameter.key value err:" + err.code)
}}); }});
}catch(e){ } catch(e) {
console.log("set unexpected error: " + e); console.log("set unexpected error: " + e);
} }
``` ```
...@@ -247,7 +247,7 @@ try { ...@@ -247,7 +247,7 @@ try {
}).catch(function (err) { }).catch(function (err) {
console.log(" set test.parameter.key error: " + err.code); console.log(" set test.parameter.key error: " + err.code);
}); });
}catch(e){ } catch(e) {
console.log("set unexpected error: " + e); console.log("set unexpected error: " + e);
} }
``` ```
...@@ -29,13 +29,13 @@ getSync(key: string, def?: string): string ...@@ -29,13 +29,13 @@ getSync(key: string, def?: string): string
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | 是 | 待查询的系统参数Key。 | | key | string | 是 | 待查询的系统参数Key。 |
| def | string | 否 | def 为所要获取的系统参数的默认值 <br> def为可选参数,仅当系统参数不存在时生效 <br>def可以传undefined(返回空)或自定义的任意值 | | def | string | 否 | def为所要获取的系统参数的默认值 <br> def为可选参数,仅当系统参数不存在时生效 <br> def可以传undefined或自定义的任意值 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| string | 系统参数值,若key不存在,返回默认值。若未指定默认值,返回空字符串。 | | string | 系统参数值 <br> 若key存在,返回设定的值。 <br> 若key不存在且def有效,返回def;若未指定def或def无效(如undefined),抛异常。 |
**示例:** **示例:**
...@@ -43,7 +43,7 @@ getSync(key: string, def?: string): string ...@@ -43,7 +43,7 @@ getSync(key: string, def?: string): string
try { try {
var info = systemparameter.getSync("const.ohos.apiversion"); var info = systemparameter.getSync("const.ohos.apiversion");
console.log(JSON.stringify(info)); console.log(JSON.stringify(info));
}catch(e){ } catch(e) {
console.log("getSync unexpected error: " + e); console.log("getSync unexpected error: " + e);
} }
``` ```
...@@ -73,7 +73,7 @@ try { ...@@ -73,7 +73,7 @@ try {
} else { } else {
console.log(" get test.parameter.key value err:" + err.code) console.log(" get test.parameter.key value err:" + err.code)
}}); }});
}catch(e){ } catch(e) {
console.log("get unexpected error: " + e); console.log("get unexpected error: " + e);
} }
``` ```
...@@ -105,7 +105,7 @@ try { ...@@ -105,7 +105,7 @@ try {
console.log(" get test.parameter.key value err:" + err.code) console.log(" get test.parameter.key value err:" + err.code)
} }
}); });
}catch(e){ } catch(e) {
console.log("get unexpected error:" + e) console.log("get unexpected error:" + e)
} }
``` ```
...@@ -123,7 +123,7 @@ get(key: string, def?: string): Promise&lt;string&gt; ...@@ -123,7 +123,7 @@ get(key: string, def?: string): Promise&lt;string&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | 是 | 待查询的系统参数Key。 | | key | string | 是 | 待查询的系统参数Key。 |
| def | string | 否 | def 为所要获取的系统参数的默认值 <br> def为可选参数,仅当系统参数不存在时生效 <br>def可以传undefined(返回空)或自定义的任意值 | | def | string | 否 | def为所要获取的系统参数的默认值 <br> def为可选参数,仅当系统参数不存在时生效 <br> def可以传undefined或自定义的任意值 |
**返回值:** **返回值:**
...@@ -141,7 +141,7 @@ try { ...@@ -141,7 +141,7 @@ try {
}).catch(function (err) { }).catch(function (err) {
console.log("get test.parameter.key error: " + err.code); console.log("get test.parameter.key error: " + err.code);
}); });
}catch(e){ } catch(e) {
console.log("get unexpected error: " + e); console.log("get unexpected error: " + e);
} }
``` ```
...@@ -166,7 +166,7 @@ setSync(key: string, value: string): void ...@@ -166,7 +166,7 @@ setSync(key: string, value: string): void
```ts ```ts
try { try {
systemparameter.setSync("test.parameter.key", "default"); systemparameter.setSync("test.parameter.key", "default");
}catch(e){ } catch(e) {
console.log("set unexpected error: " + e); console.log("set unexpected error: " + e);
} }
``` ```
...@@ -197,7 +197,7 @@ try { ...@@ -197,7 +197,7 @@ try {
} else { } else {
console.log("set test.parameter.key value err:" + err.code) console.log("set test.parameter.key value err:" + err.code)
}}); }});
}catch(e){ } catch(e) {
console.log("set unexpected error: " + e); console.log("set unexpected error: " + e);
} }
``` ```
...@@ -233,7 +233,7 @@ try { ...@@ -233,7 +233,7 @@ try {
}).catch(function (err) { }).catch(function (err) {
console.log(" set test.parameter.key error: " + err.code); console.log(" set test.parameter.key error: " + err.code);
}); });
}catch(e){ } catch(e) {
console.log("set unexpected error: " + e); console.log("set unexpected error: " + e);
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册