提交 d7c4fe66 编写于 作者: G Gloria

update docs against 8977

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 d1902321
# Media Query # Media Query
The **mediaquery** module provides different styles for different media types.
> **NOTE** > **NOTE**
> >
> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
...@@ -28,7 +30,7 @@ Sets the media query criteria and returns the corresponding listening handle. ...@@ -28,7 +30,7 @@ Sets the media query criteria and returns the corresponding listening handle.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ---------------------------------------- | | --------- | ------ | ---- | ---------------------------------------- |
| condition | string | Yes | Matching condition of a media event. For details, see "Syntax of Media Query Conditions" in [Media Query](../../ui/ui-ts-layout-mediaquery.md). | | condition | string | Yes | Matching condition of a media event. For details, see [Syntax of Media Query Conditions](../../ui/ui-ts-layout-mediaquery.md#syntax-of-media-query-conditions).|
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -36,9 +38,8 @@ Sets the media query criteria and returns the corresponding listening handle. ...@@ -36,9 +38,8 @@ Sets the media query criteria and returns the corresponding listening handle.
| MediaQueryListener | Listening handle to a media event, which is used to register or deregister the listening callback.| | MediaQueryListener | Listening handle to a media event, which is used to register or deregister the listening callback.|
**Example** **Example**
```js ```js
listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events. let listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events.
``` ```
...@@ -92,7 +93,7 @@ Deregisters a callback with the corresponding query condition by using the handl ...@@ -92,7 +93,7 @@ Deregisters a callback with the corresponding query condition by using the handl
```js ```js
import mediaquery from '@ohos.mediaquery' import mediaquery from '@ohos.mediaquery'
listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events. let listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events.
function onPortrait(mediaQueryResult) { function onPortrait(mediaQueryResult) {
if (mediaQueryResult.matches) { if (mediaQueryResult.matches) {
// do something here // do something here
...@@ -118,10 +119,9 @@ Deregisters a callback with the corresponding query condition by using the handl ...@@ -118,10 +119,9 @@ Deregisters a callback with the corresponding query condition by using the handl
### Example ### Example
```js ```ts
import mediaquery from '@ohos.mediaquery' import mediaquery from '@ohos.mediaquery'
let portraitFunc = null
@Entry @Entry
@Component @Component
...@@ -141,7 +141,7 @@ struct MediaQueryExample { ...@@ -141,7 +141,7 @@ struct MediaQueryExample {
} }
aboutToAppear() { aboutToAppear() {
portraitFunc = this.onPortrait.bind(this) // Bind the current JS instance. let portraitFunc = this.onPortrait.bind(this) // Bind the current JS instance.
this.listener.on('change', portraitFunc) this.listener.on('change', portraitFunc)
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册