diff --git a/en/application-dev/reference/apis/js-apis-display.md b/en/application-dev/reference/apis/js-apis-display.md index faaf19c4db1c1f74f530642e5d51f29b4dcd7694..1c65dc5b714318588bfe1666466003a56809f38d 100644 --- a/en/application-dev/reference/apis/js-apis-display.md +++ b/en/application-dev/reference/apis/js-apis-display.md @@ -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); ``` diff --git a/en/application-dev/reference/apis/js-apis-screenshot.md b/en/application-dev/reference/apis/js-apis-screenshot.md index 2c8e375b6123ec8d0938c1fca2823360cee823b3..59e34a4d8e14f4d8c02283e41ab24fb6182e6429 100644 --- a/en/application-dev/reference/apis/js-apis-screenshot.md +++ b/en/application-dev/reference/apis/js-apis-screenshot.md @@ -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, diff --git a/en/application-dev/windowmanager/window-guidelines.md b/en/application-dev/windowmanager/window-guidelines.md index ded781ae928fbbe72fb089c0b885903e3f569b6d..3dbbb4b74066f85a609c53a5a5a1206834c7a8ba 100644 --- a/en/application-dev/windowmanager/window-guidelines.md +++ b/en/application-dev/windowmanager/window-guidelines.md @@ -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() diff --git a/zh-cn/application-dev/reference/apis/js-apis-display.md b/zh-cn/application-dev/reference/apis/js-apis-display.md index 25b023094a532ac17c17856a681fdd470452fdd8..1a66c95b05f4d87be124fec77a52af8c0ae69700 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-display.md +++ b/zh-cn/application-dev/reference/apis/js-apis-display.md @@ -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); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md index 3e06326e131d8473a7c9b92e6283aca41dfe4c8a..6bc6496eb99320d9e820b0237e2c0deb241c7a00 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md @@ -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, diff --git a/zh-cn/application-dev/windowmanager/window-guidelines.md b/zh-cn/application-dev/windowmanager/window-guidelines.md index 52cce86f0decec5dafe0bb243812da5376baaec0..58f833570b42e3cbbd0b52a7bd435cf38f62b12d 100644 --- a/zh-cn/application-dev/windowmanager/window-guidelines.md +++ b/zh-cn/application-dev/windowmanager/window-guidelines.md @@ -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()