Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
b0f63107
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
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看板
提交
b0f63107
编写于
9月 06, 2022
作者:
G
Gloria
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update docs against 7983+8903
Signed-off-by: wusongqing<wusongqing@huawei.com>
上级
d1902321
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
80 addition
and
73 deletion
+80
-73
en/application-dev/reference/apis/js-apis-display.md
en/application-dev/reference/apis/js-apis-display.md
+80
-73
未找到文件。
en/application-dev/reference/apis/js-apis-display.md
浏览文件 @
b0f63107
...
...
@@ -35,21 +35,21 @@ Describes the attributes of a display.
**System capability**
: SystemCapability.WindowManager.WindowManager.Core
| Name
| Type| Readable| Writable| Description
|
| --------
| -------- | -------- | -------- |
-------- |
| id
| number | Yes| No| ID of the display.
|
| name
| string | Yes| No| Name of the display.
|
| alive
| boolean | Yes| No| Whether the display is alive.
|
| state
|
[
DisplayState
](
#displaystate
)
| Yes| No| State of the display.
|
| refreshRate
| number | Yes| No| Refresh rate of the display.
|
| rotation
| number | Yes| No| Screen rotation angle of the display.
|
| width
| number | Yes| No| Width of the display, in pixels.
|
| height
| number | Yes| No| Height of the display, in pixels.
|
| densityDPI
| number | Yes| No| Screen density of the display, in DPI.
|
| densityPixels | number
| Yes| No| Screen density of the display, in pixels.
|
| scaledDensity | number
| Yes| No| Scaling factor for fonts displayed on the display.
|
| xDPI
| number | Yes| No| Exact physical dots per inch of the screen in the horizontal direction.
|
| yDPI
| number | Yes| No| Exact physical dots per inch of the screen in the vertical direction.
|
| Name
| Type | Readable | Writable | Description
|
| --------
----- | ----------------------------- | -------- | -------- | ----------------------------------------------------
-------- |
| id
| number | Yes | No | ID of the display.
|
| name
| string | Yes | No | Name of the display.
|
| alive
| boolean | Yes | No | Whether the display is alive.
|
| state
|
[
DisplayState
](
#displaystate
)
| Yes | No | State of the display.
|
| refreshRate
| number | Yes | No | Refresh rate of the display.
|
| rotation
| number | Yes | No | Screen rotation angle of the display.
|
| width
| number | Yes | No | Width of the display, in pixels.
|
| height
| number | Yes | No | Height of the display, in pixels.
|
| densityDPI
| number | Yes | No | Screen density of the display, in DPI.
|
| densityPixels | number
| Yes | No | Screen density of the display, in pixels.
|
| scaledDensity | number
| Yes | No | Scaling factor for fonts displayed on the display.
|
| xDPI
| number | Yes | No | Exact physical dots per inch of the screen in the horizontal direction.
|
| yDPI
| number | Yes | No | Exact physical dots per inch of the screen in the vertical direction.
|
## display.getDefaultDisplay
...
...
@@ -61,22 +61,24 @@ Obtains the default display object. This API uses an asynchronous callback to re
**System capability**
: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
[Display](#display)
>
| Yes| Callback used to return the default display object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
[Display](#display)
>
| Yes| Callback used to return the default display object.|
**Example**
```
js
var
displayClass
=
null
;
display
.
getDefaultDisplay
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain the default display object. Code:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in obtaining the default display object. Data:
'
+
JSON
.
stringify
(
data
));
displayClass
=
data
;
});
```
```
js
var
displayClass
=
null
;
display
.
getDefaultDisplay
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain the default display object. Code:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in obtaining the default display object. Data:
'
+
JSON
.
stringify
(
data
));
displayClass
=
data
;
});
```
## display.getDefaultDisplay
...
...
@@ -88,20 +90,22 @@ Obtains the default display object. This API uses a promise to return the result
**Return value**
| Type | Description |
| ---------------------------------- | ---------------------------------------------- |
| Promise
<
[Display](#display)
>
| Promise used to return the default display object.|
| Type | Description |
| ---------------------------------- | ---------------------------------------------- |
| Promise
<
[Display](#display)
>
| Promise used to return the default display object.|
**Example**
```
js
let
promise
=
display
.
getDefaultDisplay
();
promise
.
then
(()
=>
{
console
.
log
(
'
getDefaultDisplay success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
getDefaultDisplay fail:
'
+
JSON
.
stringify
(
err
));
});
```
```
js
var
displayClass
=
null
;
let
promise
=
display
.
getDefaultDisplay
();
promise
.
then
((
data
)
=>
{
displayClass
=
data
;
console
.
info
(
'
Succeeded in obtaining the default display object. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain the default display object. Code:
'
+
JSON
.
stringify
(
err
));
});
```
## display.getDefaultDisplaySync<sup>9+</sup>
...
...
@@ -133,21 +137,21 @@ Obtains all display objects. This API uses an asynchronous callback to return th
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------- | ---- | ------------------------------- |
| callback | AsyncCallback
<
Array
<
[Display](#display)
>>
| Yes | Callback used to return all the display objects.|
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------- | ---- | ------------------------------- |
| callback | AsyncCallback
<
Array
<
[Display](#display)
>>
| Yes | Callback used to return all the display objects.|
**Example**
```
js
display
.
getAllDisplay
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain all the display objects. Code:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in obtaining all the display objects. Data:
'
+
JSON
.
stringify
(
data
))
});
```
```
js
display
.
getAllDisplay
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain all the display objects. Code:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in obtaining all the display objects. Data:
'
+
JSON
.
stringify
(
data
));
});
```
## display.getAllDisplay
...
...
@@ -159,20 +163,20 @@ Obtains all display objects. This API uses a promise to return the result.
**Return value**
| Type | Description |
| ----------------------------------------------- | ------------------------------------------------------- |
| Promise
<
Array
<
[Display](#display)
>>
| Promise used to return all the display objects.|
| Type | Description |
| ----------------------------------------------- | ------------------------------------------------------- |
| Promise
<
Array
<
[Display](#display)
>>
| Promise used to return all the display objects.|
**Example**
```
js
let
promise
=
display
.
getAllDisplay
();
promise
.
then
((
)
=>
{
console
.
log
(
'
getAllDisplay success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
getAllDisplay fail:
'
+
JSON
.
stringify
(
err
));
});
```
```
js
let
promise
=
display
.
getAllDisplay
();
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in obtaining all the display objects. Data:
'
+
JSON
.
stringify
(
data
)
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain all the display objects. Code:
'
+
JSON
.
stringify
(
err
));
});
```
## display.on('add'|'remove'|'change')
...
...
@@ -183,19 +187,20 @@ Subscribes to display changes.
**System capability**
: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.
<br>
-
**add**
, indicating the display addition event.
<br>
-
**remove**
, indicating the display removal event.
<br>
-
**change**
, indicating the display change event.|
| callback | Callback
<
number
>
| Yes| Callback used to return the ID of the display.|
**Example**
```
js
var
callback
=
(
data
)
=>
{
console
.
info
(
'
Listening enabled. Data:
'
+
JSON
.
stringify
(
data
))
}
display
.
on
(
"
add
"
,
callback
);
```
```
js
var
callback
=
(
data
)
=>
{
console
.
info
(
'
Listening enabled. Data:
'
+
JSON
.
stringify
(
data
))
}
display
.
on
(
"
add
"
,
callback
);
```
## display.off('add'|'remove'|'change')
...
...
@@ -206,12 +211,14 @@ Unsubscribes from display changes.
**System capability**
: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.
<br>
-
**add**
, indicating the display addition event.
<br>
-
**remove**
, indicating the display removal event.
<br>
-
**change**
, indicating the display change event.|
| callback | Callback
<
number
>
| No| Callback used to return the ID of the display.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.
<br>
-
**add**
, indicating the display addition event.
<br>
-
**remove**
, indicating the display removal event.
<br>
-
**change**
, indicating the display change event.|
| callback | Callback
<
number
>
| No| Callback used to return the ID of the display.|
**Example**
```
js
display
.
off
(
"
remove
"
);
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录