提交 00b9f49b 编写于 作者: W wusongqing

updated docs against 5104

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 9024154a
# Display # Display
> **NOTE** > **NOTE**<br/>
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -60,24 +59,22 @@ Obtains the default display object. ...@@ -60,24 +59,22 @@ Obtains the default display object.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- | | callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the default display object.|
| callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the default display object.|
**Example** **Example**
```js
```js var displayClass = null;
var displayClass = null; display.getDefaultDisplay((err, data) => {
display.getDefaultDisplay((err, data) => { if (err.code) {
if (err.code) { console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err));
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err)); return;
return; }
} console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); displayClass = data;
displayClass = data; });
}); ```
```
## display.getDefaultDisplay ## display.getDefaultDisplay
...@@ -89,20 +86,20 @@ Obtains the default display object. ...@@ -89,20 +86,20 @@ Obtains the default display object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ---------------------------------------------- | | ---------------------------------- | ---------------------------------------------- |
| Promise&lt;[Display](#display)&gt; | Promise used to return the default display object.| | Promise&lt;[Display](#display)&gt; | Promise used to return the default display object.|
**Example** **Example**
```js ```js
let promise = display.getDefaultDisplay(); let promise = display.getDefaultDisplay();
promise.then(() => { promise.then(() => {
console.log('getDefaultDisplay success'); console.log('getDefaultDisplay success');
}).catch((err) => { }).catch((err) => {
console.log('getDefaultDisplay fail: ' + JSON.stringify(err)); console.log('getDefaultDisplay fail: ' + JSON.stringify(err));
}); });
``` ```
## display.getAllDisplay ## display.getAllDisplay
...@@ -114,21 +111,21 @@ Obtains all the display objects. ...@@ -114,21 +111,21 @@ Obtains all the display objects.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------- | ---- | ------------------------------- | | -------- | ---------------------------------------------------- | ---- | ------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[Display](#display)&gt;&gt; | Yes | Callback used to return all the display objects.| | callback | AsyncCallback&lt;Array&lt;[Display](#display)&gt;&gt; | Yes | Callback used to return all the display objects.|
**Example** **Example**
```js ```js
display.getAllDisplay((err, data) => { display.getAllDisplay((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)) console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data))
}); });
``` ```
## display.getAllDisplay ## display.getAllDisplay
...@@ -140,20 +137,20 @@ Obtains all the display objects. ...@@ -140,20 +137,20 @@ Obtains all the display objects.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------------------------------------- | ------------------------------------------------------- | | ----------------------------------------------- | ------------------------------------------------------- |
| Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return an array containing all the display objects.| | Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return an array containing all the display objects.|
**Example** **Example**
```js ```js
let promise = display.getAllDisplay(); let promise = display.getAllDisplay();
promise.then(() => { promise.then(() => {
console.log('getAllDisplay success'); console.log('getAllDisplay success');
}).catch((err) => { }).catch((err) => {
console.log('getAllDisplay fail: ' + JSON.stringify(err)); console.log('getAllDisplay fail: ' + JSON.stringify(err));
}); });
``` ```
## display.on('add'|'remove'|'change') ## display.on('add'|'remove'|'change')
...@@ -164,21 +161,18 @@ Enables listening. ...@@ -164,21 +161,18 @@ Enables listening.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- | | type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed|
| type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed| | callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.|
| callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.|
**Example** **Example**
```js
```js var callback = (data) => {
var type = "add"; console.info('Listening enabled. Data: ' + JSON.stringify(data))
var callback = (data) => { }
console.info('Listening enabled. Data: ' + JSON.stringify(data)) display.on("add", callback);
} ```
display.on(type, callback);
```
## display.off('add'|'remove'|'change') ## display.off('add'|'remove'|'change')
...@@ -190,15 +184,12 @@ Disables listening. ...@@ -190,15 +184,12 @@ Disables listening.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- | | type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed|
| type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed| | callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.|
| callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.|
**Example** **Example**
```js
```js display.off("remove");
var type = "remove"; ```
display.off(type);
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册