| 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**
| Type | Description |
...
...
@@ -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.|
**Example**
```js
listener=mediaquery.matchMediaSync('(orientation: landscape)');// Listen for landscape events.
letlistener=mediaquery.matchMediaSync('(orientation: landscape)');// Listen for landscape events.
```
...
...
@@ -92,7 +93,7 @@ Deregisters a callback with the corresponding query condition by using the handl
```js
importmediaqueryfrom'@ohos.mediaquery'
listener=mediaquery.matchMediaSync('(orientation: landscape)');// Listen for landscape events.
letlistener=mediaquery.matchMediaSync('(orientation: landscape)');// Listen for landscape events.
functiononPortrait(mediaQueryResult){
if(mediaQueryResult.matches){
// do something here
...
...
@@ -118,10 +119,9 @@ Deregisters a callback with the corresponding query condition by using the handl
### Example
```js
```ts
importmediaqueryfrom'@ohos.mediaquery'
letportraitFunc=null
@Entry
@Component
...
...
@@ -141,7 +141,7 @@ struct MediaQueryExample {
}
aboutToAppear(){
portraitFunc=this.onPortrait.bind(this)// Bind the current JS instance.
letportraitFunc=this.onPortrait.bind(this)// Bind the current JS instance.