未验证 提交 aed94cdf 编写于 作者: L LiAn 提交者: Gitee

update zh-cn/application-dev/reference/apis/js-apis-mediaquery.md.

Signed-off-by: NLiAn <lian15@huawei.com>
上级 928a0045
......@@ -80,16 +80,18 @@ off(type: 'change', callback?: Callback&lt;MediaQueryResult&gt;): void
- 示例
```
listener = mediaquery.matchMediaSync('(orientation: landscape)'); //监听横屏事件
onPortrait(mediaQueryResult) {
import mediaquery from '@ohos.mediaquery'
let listener = mediaquery.matchMediaSync('(orientation: landscape)'); //监听横屏事件
function onPortrait(mediaQueryResult) {
if (mediaQueryResult.matches) {
// do something here
} else {
// do something here
}
}
listener.on('change', onPortrait) // 注册回调
listener.off('change', onPortrait) // 去注册回调
this.listener.on('change', this.onPortrait) // 注册回调
this.listener.off('change', this.onPortrait) // 去注册回调
```
......@@ -141,5 +143,3 @@ struct MediaQueryExample {
}
}
```
\ No newline at end of file
![zh-cn_image_0000001174422920](figures/zh-cn_image_0000001174422920.gif)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册