未验证 提交 fe992e51 编写于 作者: O openharmony_ci 提交者: Gitee

!3523 窗口管理display/screenshot示例代码语言标记:无需翻译

Merge pull request !3523 from 葛亚芳/master
......@@ -5,7 +5,7 @@
## Modules to Import
```
```js
import display from '@ohos.display';
```
......@@ -64,7 +64,8 @@ Obtains the default display object.
| 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) {
......@@ -92,7 +93,7 @@ Obtains the default display object.
- Example
```
```js
let promise = display.getDefaultDisplay();
promise.then(() => {
console.log('getDefaultDisplay success');
......@@ -117,7 +118,7 @@ Obtains 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));
......@@ -143,7 +144,7 @@ Obtains all the display objects.
- Example
```
```js
let promise = display.getAllDisplay();
promise.then(() => {
console.log('getAllDisplay success');
......@@ -167,7 +168,8 @@ Enables listening.
| callback | Callback<number> | Yes| Callback used to return the ID of the display.|
- Example
```
```js
var type = "add";
var callback = (data) => {
console.info('Listening enabled. Data: ' + JSON.stringify(data))
......@@ -191,7 +193,8 @@ Disables listening.
| callback | Callback<number> | No| Callback used to return the ID of the display.|
- Example
```
```js
var type = "remove";
display.off(type);
```
......@@ -5,7 +5,7 @@
## Modules to Import
```
```js
import screenshot from '@ohos.screenshot';
```
......@@ -67,7 +67,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal
- Example
```
```js
var ScreenshotOptions = {
"screenRect": {
"left": 200,
......@@ -112,7 +112,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro
- Example
```
```js
var ScreenshotOptions = {
"screenRect": {
"left": 200,
......
......@@ -25,7 +25,7 @@ Currently, the main window is automatically created when the application is star
### Creating a Subwindow
You can call **create** to create a subwindow. The sample code is as follows:
```
```js
import window from '@ohos.window';
var windowClass = null;
let promise = window.create("subWindow", window.WindowType.TYPE_APP);
......@@ -41,7 +41,7 @@ You can call **create** to create a subwindow. The sample code is as follows:
- Call **getTopWindow** to obtain the top window of the application. The sample code is as follows:
```
```js
var windowClass = null;
let promise = window.getTopWindow();
promise.then((data)=> {
......@@ -54,7 +54,7 @@ You can call **create** to create a subwindow. The sample code is as follows:
- You can also call **find** to obtain created subwindows in the application. The sample code is as follows:
```
```js
var windowClass = null;
let promise = window.find("subWindow");
promise.then((data)=> {
......@@ -69,7 +69,7 @@ You can call **create** to create a subwindow. The sample code is as follows:
After a window object is obtained, you can call **hide** and **destroy** to hide and destroy the window object, respectively. The sample code is as follows:
```
```js
let promise = windowClass.hide();
promise.then((data)=> {
console.info('window hidden. Data: ' + JSON.stringify(data))
......@@ -91,7 +91,7 @@ After a window object is obtained, you can call **setFullScreen** to enable the
The sample code is as follows:
```
```js
import window from '@ohos.window';
try {
const win = await window.getTopWindow()
......
......@@ -5,7 +5,7 @@
## 导入模块
```
```js
import display from '@ohos.display';
```
......@@ -64,7 +64,7 @@ getDefaultDisplay(callback: AsyncCallback<Display>): void
| callback | AsyncCallback<[Display](#display)> | 是 | 回调返回当前默认的display对象。 |
- 示例
```
```js
var displayClass = null;
display.getDefaultDisplay((err, data) => {
if (err.code) {
......@@ -92,7 +92,7 @@ getDefaultDisplay(): Promise<Display>
- 示例
```
```js
let promise = display.getDefaultDisplay();
promise.then(() => {
console.log('getDefaultDisplay success');
......@@ -117,7 +117,7 @@ getAllDisplay(callback: AsyncCallback<Array<Display>>): void
- 示例
```
```js
display.getAllDisplay((err, data) => {
if (err.code) {
console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
......@@ -143,7 +143,7 @@ getAllDisplay(): Promise<Array<Display>>
- 示例
```
```js
let promise = display.getAllDisplay();
promise.then(() => {
console.log('getAllDisplay success');
......@@ -167,7 +167,7 @@ on(type: 'add'|'remove'|'change', callback: Callback<number>): void
| callback | Callback<number> | 是 | 回调返回监听到的显示设备的id。 |
- 示例
```
```js
var type = "add";
var callback = (data) => {
console.info('Listening enabled. Data: ' + JSON.stringify(data))
......@@ -191,7 +191,7 @@ off(type: 'add'|'remove'|'change', callback?: Callback<number>): void
| callback | Callback<number> | 否 | 回调返回监听到的显示设备的id。 |
- 示例
```
```js
var type = "remove";
display.off(type);
```
......@@ -5,7 +5,7 @@
## 导入模块
```
```js
import screenshot from '@ohos.screenshot';
```
......@@ -67,7 +67,7 @@ save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>)
- 示例
```
```js
var ScreenshotOptions = {
"screenRect": {
"left": 200,
......@@ -112,7 +112,7 @@ save(options?: ScreenshotOptions): Promise<image.PixelMap>
- 示例
```
```js
var ScreenshotOptions = {
"screenRect": {
"left": 200,
......
......@@ -25,7 +25,7 @@
### 创建子窗口
当前可以通过`create`接口创建子窗口。具体示例代码如下:
```
```js
import window from '@ohos.window';
var windowClass = null;
let promise = window.create("subWindow", window.WindowType.TYPE_APP);
......@@ -41,7 +41,7 @@
- 应用内可以通过`getTopWindow`来获取当前应用内最后显示的窗口。具体示例代码如下:
```
```js
var windowClass = null;
let promise = window.getTopWindow();
promise.then((data)=> {
......@@ -54,7 +54,7 @@
- 应用内也可以通过`Find`来获取已经创建的子窗口。具体示例代码如下:
```
```js
var windowClass = null;
let promise = window.find("subWindow");
promise.then((data)=> {
......@@ -69,7 +69,7 @@
在已经获取到窗口对象的前提下,可以调用`hide``destroy`来隐藏和销毁已经创建的窗口对象。具体示例代码如下:
```
```js
let promise = windowClass.hide();
promise.then((data)=> {
console.info('window hidden. Data: ' + JSON.stringify(data))
......@@ -91,7 +91,7 @@
示例代码如下:
```
```js
import window from '@ohos.window';
try {
const win = await window.getTopWindow()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册