| condition | string | Yes | Matching condition of a media event.|
| 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). |
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| ------------------ | ---------------------- |
| ------------------ | ---------------------- |
| MediaQueryListener | Listening handle to a media event, which is used to register or unregister 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.
listener=mediaquery.matchMediaSync('(orientation: landscape)');// Listen for landscape events.
| type | boolean | Yes | Must enter the string **change**. |
| type | boolean | Yes | Must enter the string **change**. |
| callback | Callback<MediaQueryResult> | No | Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered.|
| callback | Callback<MediaQueryResult> | No | Callback to be deregistered. If the default value is used, all callbacks of the handle are deregistered.|
**Example**
**Example**
```js
```js
...
@@ -92,7 +101,7 @@ Unregisters a callback with the corresponding query condition by using the handl
...
@@ -92,7 +101,7 @@ Unregisters a callback with the corresponding query condition by using the handl
}
}
}
}
listener.on('change',onPortrait)// Register a callback.
listener.on('change',onPortrait)// Register a callback.
listener.off('change',onPortrait)// Unregister a callback.
listener.off('change',onPortrait)// Deregister a callback.
```
```
...
@@ -132,7 +141,7 @@ struct MediaQueryExample {
...
@@ -132,7 +141,7 @@ struct MediaQueryExample {
}
}
aboutToAppear(){
aboutToAppear(){
portraitFunc=this.onPortrait.bind(this)//bind current js instance
portraitFunc=this.onPortrait.bind(this)// Bind the current JS instance.