未验证 提交 08fd63c8 编写于 作者: O openharmony_ci 提交者: Gitee

!8249 翻译完成:7305 update docs

Merge pull request !8249 from wusongqing/TR7305V2
# Media Query
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**
>
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.mediaquery`](js-apis-mediaquery.md) instead.
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -38,11 +39,7 @@ Creates a **MediaQueryList** object based on the query condition.
**Example**
```
export default {
matchMedia() {
var mMediaQueryList = mediaquery.matchMedia('(max-width: 466)');
},
}
var mMediaQueryList = mediaquery.matchMedia('(max-width: 466)');
```
## MediaQueryEvent
......@@ -95,11 +92,16 @@ Adds a listener for this **MediaQueryList** object. The listener must be added b
| Name | Type | Mandatory | Description |
| -------- | -------------------------------- | ---- | -------------- |
| callback | (event: MediaQueryEvent) => void | Yes | Callback invoked when the matching condition changes.|
| callback | (event: MediaQueryEvent) => void | Yes | Callback invoked when the query condition changes.|
**Example**
```
function maxWidthMatch(){
if(e.mathes){
// do something
}
}
mMediaQueryList.addListener(maxWidthMatch);
```
......@@ -108,7 +110,7 @@ mMediaQueryList.addListener(maxWidthMatch);
removeListener(callback: (event: MediaQueryEvent) => void): void
Removes the listener for this **MediaQueryList** object.
Removes the listener for this **MediaQueryList** object.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
......@@ -116,10 +118,15 @@ Removes the listener for this **MediaQueryList** object.
| Name | Type | Mandatory | Description |
| -------- | --------------------------------- | ---- | -------------- |
| callback | (event: MediaQueryEvent) => void) | Yes | Callback invoked when the matching condition changes.|
| callback | (event: MediaQueryEvent) => void) | Yes | Callback invoked when the query condition changes.|
**Example**
```
function maxWidthMatch(){
if(e.mathes){
// do something
}
}
mMediaQueryList.removeListener(maxWidthMatch);
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册