| 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).|
...
...
@@ -37,7 +38,7 @@ Sets the media query criteria and returns the corresponding listening handle.
**Example**
```js
listener=mediaquery.matchMediaSync('(orientation: landscape)');// Listen for landscape events.
letlistener=mediaquery.matchMediaSync('(orientation: landscape)');// Listen for landscape events.
```
...
...
@@ -66,7 +67,7 @@ Registers a callback with the corresponding query condition by using the handle.
| type | string | Yes | Must enter the string **'change'**.|
| type | string | Yes | Must enter the string **change**.|
| callback | Callback<MediaQueryResult> | Yes | Callback registered with media query. |
**Example**
...
...
@@ -88,7 +89,7 @@ Deregisters a callback with the corresponding query condition by using the handl
| callback | Callback<MediaQueryResult> | No | Callback to be deregistered. If the default value is used, all callbacks of the handle are deregistered.|
**Example**
```js
```ts
importmediaqueryfrom'@ohos.mediaquery'
letlistener=mediaquery.matchMediaSync('(orientation: landscape)');// Listen for landscape events.
...
...
@@ -117,10 +118,9 @@ Deregisters a callback with the corresponding query condition by using the handl
### Example
```js
```ts
importmediaqueryfrom'@ohos.mediaquery'
letportraitFunc=null
@Entry
@Component
...
...
@@ -140,7 +140,7 @@ struct MediaQueryExample {
}
aboutToAppear(){
portraitFunc=this.onPortrait.bind(this)//bind current js instance
letportraitFunc=this.onPortrait.bind(this)// Bind the current JS instance.