Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
449ce282
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
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看板
未验证
提交
449ce282
编写于
5月 31, 2022
作者:
O
openharmony_ci
提交者:
Gitee
5月 31, 2022
浏览文件
操作
浏览文件
下载
差异文件
!4670 更新代码示例
Merge pull request !4670 from wpgavin/master
上级
4f0b17a1
f58cedf6
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
52 addition
and
48 deletion
+52
-48
zh-cn/application-dev/reference/apis/js-apis-resource-manager.md
...pplication-dev/reference/apis/js-apis-resource-manager.md
+52
-48
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-resource-manager.md
浏览文件 @
449ce282
...
...
@@ -29,14 +29,14 @@ getResourceManager(callback: AsyncCallback<ResourceManager>): void
```
resourceManager.getResourceManager((error, mgr) => {
if (error != null) {
console.log("error
occurs
" + error);
console.log("error
is
" + error);
return;
}
mgr.getString(0x1000000, (error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
} else {
console.log(value)
;
let str = value
;
}
});
});
...
...
@@ -82,13 +82,13 @@ getResourceManager(): Promise<ResourceManager>
resourceManager.getResourceManager().then(mgr => {
mgr.getString(0x1000000, (error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
} else {
console.log(value)
;
let str = value
;
}
});
}).catch(error => {
console.log(error);
console.log(
"error is " +
error);
});
```
...
...
@@ -182,8 +182,8 @@ getResourceManager(bundleName: string): Promise<ResourceManager>
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getConfiguration((error, value) => {
console.log(value.direction)
;
console.log(value.locale)
;
let direction = value.direction
;
let locale = value.locale
;
});
});
```
...
...
@@ -205,8 +205,8 @@ resourceManager.getResourceManager((error, mgr) => {
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getDeviceCapability((error, value) => {
console.log(value.screenDensity)
;
console.log(value.deviceType)
;
let screenDensity = value.screenDensity
;
let deviceType = value.deviceType
;
});
});
```
...
...
@@ -252,9 +252,9 @@ getString(resId: number, callback: AsyncCallback<string>): void
resourceManager.getResourceManager((error, mgr) => {
mgr.getString($r('app.string.test').id, (error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
} else {
console.log(value)
;
let str = value
;
}
});
});
...
...
@@ -283,9 +283,9 @@ getString(resId: number): Promise<string>
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getString($r('app.string.test').id).then(value => {
console.log(value)
;
let str = value
;
}).catch(error => {
console.log("getstring promise " + error);
console.log("getstring promise
error is
" + error);
});
});
```
...
...
@@ -310,9 +310,9 @@ getStringArray(resId: number, callback: AsyncCallback<Array<string>>
resourceManager.getResourceManager((error, mgr) => {
mgr.getStringArray($r('app.strarray.test').id, (error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
} else {
console.log(value)
;
let strArray = value
;
}
});
});
...
...
@@ -341,9 +341,9 @@ getStringArray(resId: number): Promise<Array<string>>
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getStringArray($r('app.strarray.test').id).then(value => {
console.log(value)
;
let strArray = value
;
}).catch(error => {
console.log("get
string promise
" + error);
console.log("get
StringArray promise error is
" + error);
});
});
```
...
...
@@ -368,9 +368,9 @@ getMedia(resId: number, callback: AsyncCallback<Uint8Array>): void
resourceManager.getResourceManager((error, mgr) => {
mgr.getMedia($r('app.media.test').id, (error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
} else {
console.log(value)
;
let media = value
;
}
});
});
...
...
@@ -399,9 +399,9 @@ getMedia(resId: number): Promise<Uint8Array>
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getMedia($r('app.media.test').id).then(value => {
console.log(value)
;
let media = value
;
}).catch(error => {
console.log("get
string promise
" + error);
console.log("get
Media promise error is
" + error);
});
});
```
...
...
@@ -426,9 +426,9 @@ getMediaBase64(resId: number, callback: AsyncCallback<string>): void
resourceManager.getResourceManager((error, mgr) => {
mgr.getMediaBase64($r('app.media.test').id, (error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
} else {
console.log(value)
;
let media = value
;
}
});
});
...
...
@@ -457,9 +457,9 @@ getMediaBase64(resId: number): Promise<string>
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getMediaBase64($r('app.media.test').id).then(value => {
console.log(value)
;
let media = value
;
}).catch(error => {
console.log("get
string promise
" + error);
console.log("get
MediaBase64 promise error is
" + error);
});
});
```
...
...
@@ -483,9 +483,10 @@ getConfiguration(callback: AsyncCallback<Configuration>): void
resourceManager.getResourceManager((error, mgr) => {
mgr.getConfiguration((error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
} else {
console.log(value);
let direction = value.direction;
let locale = value.locale;
}
});
});
...
...
@@ -509,9 +510,10 @@ getConfiguration(): Promise<Configuration>
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getConfiguration().then(value => {
console.log(value);
let direction = value.direction;
let locale = value.locale;
}).catch(error => {
console.log("get
string promise
" + error);
console.log("get
Configuration promise error is
" + error);
});
});
```
...
...
@@ -535,9 +537,10 @@ getDeviceCapability(callback: AsyncCallback<DeviceCapability>): void
resourceManager.getResourceManager((error, mgr) => {
mgr.getDeviceCapability((error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
} else {
console.log(value);
let screenDensity = value.screenDensity;
let deviceType = value.deviceType;
}
});
});
...
...
@@ -561,9 +564,10 @@ getDeviceCapability(): Promise<DeviceCapability>
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getDeviceCapability().then(value => {
console.log(value);
let screenDensity = value.screenDensity;
let deviceType = value.deviceType;
}).catch(error => {
console.log("get
string promise
" + error);
console.log("get
DeviceCapability promise error is
" + error);
});
});
```
...
...
@@ -589,9 +593,9 @@ getPluralString(resId: number, num: number, callback: AsyncCallback<string>
resourceManager.getResourceManager((error, mgr) => {
mgr.getPluralString($r("app.plural.test").id, 1, (error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
} else {
console.log(value)
;
let str = value
;
}
});
});
...
...
@@ -621,9 +625,9 @@ getPluralString(resId: number, num: number): Promise<string>
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getPluralString($r("app.plural.test").id, 1).then(value => {
console.log(value)
;
let str = value
;
}).catch(error => {
console.log("get
string promise
" + error);
console.log("get
PluralString promise error is
" + error);
});
});
```
...
...
@@ -647,9 +651,9 @@ getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void
resourceManager.getResourceManager((error, mgr) => {
mgr.getRawFile("test.xml", (error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
} else {
console.log(value)
;
let rawFile = value
;
}
});
});
...
...
@@ -677,9 +681,9 @@ getRawFile(path: string): Promise<Uint8Array>
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getRawFile("test.xml").then(value => {
console.log(value)
;
let rawFile = value
;
}).catch(error => {
console.log("get
rawfile promise
" + error);
console.log("get
RawFile promise error is
" + error);
});
});
```
...
...
@@ -703,7 +707,7 @@ getRawFileDescriptor(path: string, callback: AsyncCallback<RawFileDescriptor&
resourceManager.getResourceManager((error, mgr) => {
mgr.getRawFileDescriptor("test.xml", (error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
} else {
let fd = value.fd;
let offset = value.offset;
...
...
@@ -739,7 +743,7 @@ getRawFileDescriptor(path: string): Promise<RawFileDescriptor>
let offset = value.offset;
let length = value.length;
}).catch(error => {
console.log("getRawFileDescriptor promise " + error);
console.log("getRawFileDescriptor promise
error is
" + error);
});
});
```
...
...
@@ -763,7 +767,7 @@ closeRawFileDescriptor(path: string, callback: AsyncCallback<void>): void
resourceManager.getResourceManager((error, mgr) => {
mgr.closeRawFileDescriptor("test.xml", (error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
}
});
});
...
...
@@ -791,9 +795,9 @@ closeRawFileDescriptor(path: string): Promise<void>
```
resourceManager.getResourceManager((error, mgr) => {
mgr.closeRawFileDescriptor("test.xml").then(value => {
console.log(value)
;
let result = value
;
}).catch(error => {
console.log("closeRawFileDescriptor promise " + error);
console.log("closeRawFileDescriptor promise
error is
" + error);
});
});
```
...
...
@@ -811,7 +815,7 @@ release()
resourceManager.getResourceManager((error, mgr) => {
mgr.release((error, value) => {
if (error != null) {
console.log(
value
);
console.log(
"error is " + error
);
}
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录