提交 22ce4f59 编写于 作者: 谢凯明
上级 83fbd3d7
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
## 导入模块 ## 导入模块
```js ```ts
import configPolicy from '@ohos.configPolicy'; import configPolicy from '@ohos.configPolicy';
``` ```
...@@ -31,8 +31,10 @@ getOneCfgFile(relPath: string, callback: AsyncCallback<string>) ...@@ -31,8 +31,10 @@ getOneCfgFile(relPath: string, callback: AsyncCallback<string>)
| callback | AsyncCallback<string> | 是 | 异步回调,用于返回最高优先级配置文件的路径 | | callback | AsyncCallback<string> | 是 | 异步回调,用于返回最高优先级配置文件的路径 |
**示例:** **示例:**
```js ```ts
configPolicy.getOneCfgFile('etc/config.xml', (error, value) => { import { BusinessError } from '@ohos.base';
configPolicy.getOneCfgFile('etc/config.xml', (error: BusinessError, value: string) => {
if (error == null) { if (error == null) {
console.log("value is " + value); console.log("value is " + value);
} else { } else {
...@@ -63,10 +65,12 @@ getOneCfgFile(relPath: string): Promise<string> ...@@ -63,10 +65,12 @@ getOneCfgFile(relPath: string): Promise<string>
| Promise<string> | 最高优先级配置文件的路径 | | Promise<string> | 最高优先级配置文件的路径 |
**示例:** **示例:**
```js ```ts
configPolicy.getOneCfgFile('etc/config.xml').then(value => { import { BusinessError } from '@ohos.base';
configPolicy.getOneCfgFile('etc/config.xml').then((value: string) => {
console.log("value is " + value); console.log("value is " + value);
}).catch(error => { }).catch((error: BusinessError) => {
console.log("getOneCfgFile promise " + error); console.log("getOneCfgFile promise " + error);
}); });
``` ```
...@@ -89,8 +93,10 @@ getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>) ...@@ -89,8 +93,10 @@ getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>)
| callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回文件列表 | | callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回文件列表 |
**示例:** **示例:**
```js ```ts
configPolicy.getCfgFiles('etc/config.xml', (error, value) => { import { BusinessError } from '@ohos.base';
configPolicy.getCfgFiles('etc/config.xml', (error: BusinessError, value: Array<string>) => {
if (error == null) { if (error == null) {
console.log("value is " + value); console.log("value is " + value);
} else { } else {
...@@ -121,10 +127,12 @@ getCfgFiles(relPath: string): Promise&lt;Array&lt;string&gt;&gt; ...@@ -121,10 +127,12 @@ getCfgFiles(relPath: string): Promise&lt;Array&lt;string&gt;&gt;
| Promise&lt;Array&lt;string&gt;&gt; | 文件列表 | | Promise&lt;Array&lt;string&gt;&gt; | 文件列表 |
**示例:** **示例:**
```js ```ts
configPolicy.getCfgFiles('etc/config.xml').then(value => { import { BusinessError } from '@ohos.base';
configPolicy.getCfgFiles('etc/config.xml').then((value: Array<string>) => {
console.log("value is " + value); console.log("value is " + value);
}).catch(error => { }).catch((error: BusinessError) => {
console.log("getCfgFiles promise " + error); console.log("getCfgFiles promise " + error);
}); });
``` ```
...@@ -145,8 +153,10 @@ getCfgDirList(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;) ...@@ -145,8 +153,10 @@ getCfgDirList(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;)
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 异步回调,用于返回配置层级目录列表 | | callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 异步回调,用于返回配置层级目录列表 |
**示例:** **示例:**
```js ```ts
configPolicy.getCfgDirList((error, value) => { import { BusinessError } from '@ohos.base';
configPolicy.getCfgDirList((error: BusinessError, value: Array<string>) => {
if (error == null) { if (error == null) {
console.log("value is " + value); console.log("value is " + value);
} else { } else {
...@@ -171,10 +181,12 @@ getCfgDirList(): Promise&lt;Array&lt;string&gt;&gt; ...@@ -171,10 +181,12 @@ getCfgDirList(): Promise&lt;Array&lt;string&gt;&gt;
| Promise&lt;Array&lt;string&gt;&gt; | 配置层级目录列表 | | Promise&lt;Array&lt;string&gt;&gt; | 配置层级目录列表 |
**示例:** **示例:**
```js ```ts
configPolicy.getCfgDirList().then(value => { import { BusinessError } from '@ohos.base';
configPolicy.getCfgDirList().then((value: Array<string>) => {
console.log("value is " + value); console.log("value is " + value);
}).catch(error => { }).catch((error: BusinessError) => {
console.log("getCfgDirList promise " + error); console.log("getCfgDirList promise " + error);
}); });
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册