未验证 提交 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 ...@@ -80,16 +80,18 @@ off(type: 'change', callback?: Callback&lt;MediaQueryResult&gt;): void
- 示例 - 示例
``` ```
listener = mediaquery.matchMediaSync('(orientation: landscape)'); //监听横屏事件 import mediaquery from '@ohos.mediaquery'
onPortrait(mediaQueryResult) {
if (mediaQueryResult.matches) { let listener = mediaquery.matchMediaSync('(orientation: landscape)'); //监听横屏事件
// do something here function onPortrait(mediaQueryResult) {
} else { if (mediaQueryResult.matches) {
// do something here // 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) // 去注册回调
``` ```
...@@ -140,6 +142,4 @@ struct MediaQueryExample { ...@@ -140,6 +142,4 @@ struct MediaQueryExample {
.width('100%').height('100%') .width('100%').height('100%')
} }
} }
``` ```
\ 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.
先完成此消息的编辑!
想要评论请 注册