提交 549a6129 编写于 作者: W wusongqing

updated against against 5489

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 0729632e
# Media Query # Media Query
> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE** > **NOTE**
>
> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
``` ```js
import mediaquery from '@ohos.mediaquery' import mediaquery from '@ohos.mediaquery'
``` ```
...@@ -22,19 +23,19 @@ matchMediaSync(condition: string): MediaQueryListener ...@@ -22,19 +23,19 @@ matchMediaSync(condition: string): MediaQueryListener
Sets the media query criteria and returns the corresponding listening handle. Sets the media query criteria and returns the corresponding listening handle.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | --------- | ------ | ---- | ---------- |
| condition | string | Yes| Matching condition of a media event.| | condition | string | Yes | Matching condition of a media event.|
- 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 unregister the listening callback.|
- Example **Example**
``` ```js
listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events. listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events.
``` ```
...@@ -45,10 +46,10 @@ Media query handle, including the first query result when the handle is applied ...@@ -45,10 +46,10 @@ Media query handle, including the first query result when the handle is applied
### Attributes ### Attributes
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ------- | ------- | ---- | ---- | ---------- |
| matches | boolean | Yes| No| Whether the match condition is met.| | matches | boolean | Yes | No | Whether the match condition is met. |
| media | string | Yes| No| Matching condition of a media event.| | media | string | Yes | No | Matching condition of a media event.|
### on ### on
...@@ -57,13 +58,13 @@ on(type: 'change', callback: Callback&lt;MediaQueryResult&gt;): void ...@@ -57,13 +58,13 @@ on(type: 'change', callback: Callback&lt;MediaQueryResult&gt;): void
Registers a callback with the corresponding query condition by using the handle. This callback is triggered when the media attributes change. Registers a callback with the corresponding query condition by using the handle. This callback is triggered when the media attributes change.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------------------------------- | ---- | ---------------- |
| type | string | Yes| Must enter the string **change**.| | type | string | Yes | Must enter the string **change**.|
| callback | Callback&lt;MediaQueryResult&gt; | Yes| Callback registered with media query.| | callback | Callback&lt;MediaQueryResult&gt; | Yes | Callback registered with media query. |
- Example **Example**
For details, see [off Example](#off). For details, see [off Example](#off).
...@@ -72,14 +73,14 @@ Registers a callback with the corresponding query condition by using the handle. ...@@ -72,14 +73,14 @@ Registers a callback with the corresponding query condition by using the handle.
off(type: 'change', callback?: Callback&lt;MediaQueryResult&gt;): void off(type: 'change', callback?: Callback&lt;MediaQueryResult&gt;): void
Unregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change. Unregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------------------------------- | ---- | ----------------------------- |
| type | boolean | Yes| Must enter the string **change**.| | type | boolean | Yes | Must enter the string **change**. |
| callback | Callback&lt;MediaQueryResult&gt; | No| Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered.| | callback | Callback&lt;MediaQueryResult&gt; | No | Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered.|
- Example **Example**
``` ```js
import mediaquery from '@ohos.mediaquery' import mediaquery from '@ohos.mediaquery'
listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events. listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events.
...@@ -90,8 +91,8 @@ Unregisters a callback with the corresponding query condition by using the handl ...@@ -90,8 +91,8 @@ Unregisters a callback with the corresponding query condition by using the handl
// do something here // do something here
} }
} }
this.listener.on('change', this.onPortrait) // Registration callback. listener.on('change', onPortrait) // Register a callback.
this.listener.off('change', this.onPortrait) // Deregistration callback. listener.off('change', onPortrait) // Unregister a callback.
``` ```
...@@ -100,15 +101,15 @@ Unregisters a callback with the corresponding query condition by using the handl ...@@ -100,15 +101,15 @@ Unregisters a callback with the corresponding query condition by using the handl
### Attributes ### Attributes
| Name| Type| Readable| Writable| Description| | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | ------- | ------- | ---- | ---- | ---------- |
| matches | boolean | Yes| No| Whether the match condition is met.| | matches | boolean | Yes | No | Whether the match condition is met. |
| media | string | Yes| No| Matching condition of a media event.| | media | string | Yes | No | Matching condition of a media event.|
### Example ### Example
``` ```js
import mediaquery from '@ohos.mediaquery' import mediaquery from '@ohos.mediaquery'
let portraitFunc = null let portraitFunc = null
......
# Prompt # Prompt
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
> >
> - The APIs of this module are no longer maintained since API version 8. You are advised to use ['@ohos.prompt](js-apis-prompt.md)' instead. > - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.prompt`](js-apis-prompt.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. > - 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.
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
## Modules to Import ## Modules to Import
``` ```js
import prompt from '@system.prompt'; import prompt from '@system.prompt';
``` ```
...@@ -25,13 +25,13 @@ Shows the toast. ...@@ -25,13 +25,13 @@ Shows the toast.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------------- | --------- | ------------------------------ | | ------- | ------------------------------------- | ---- | --------------- |
| options | [ShowToastOptions](#showtoastoptions) | Yes | Options for showing the toast. | | options | [ShowToastOptions](#showtoastoptions) | Yes | Options for showing the toast.|
**Example** **Example**
``` ```js
export default { export default {
showToast() { showToast() {
prompt.showToast({ prompt.showToast({
...@@ -53,14 +53,14 @@ Shows the dialog box. ...@@ -53,14 +53,14 @@ Shows the dialog box.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | --------------------------------------- | --------- | ----------------------------------- | | ------- | --------------------------------------- | ---- | ----------- |
| options | [ShowDialogOptions](#showdialogoptions) | Yes | Options for showing the dialog box. | | options | [ShowDialogOptions](#showdialogoptions) | Yes | Options for showing the dialog box.|
**Example** **Example**
``` ```js
export default { export default {
showDialog() { showDialog() {
prompt.showDialog({ prompt.showDialog({
...@@ -93,14 +93,14 @@ Shows the action menu. ...@@ -93,14 +93,14 @@ Shows the action menu.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ---------------------------------------- | --------- | ------------------------------------ | | ------- | ---------------------------------------- | ---- | -------------------- |
| options | [ShowActionMenuOptions](#showactionmenuoptions) | Yes | Options for showing the action menu. | | options | [ShowActionMenuOptions](#showactionmenuoptions) | Yes | Options for showing the action menu.|
**Example** **Example**
``` ```js
export default { export default {
showActionMenu() { showActionMenu() {
prompt.showActionMenu({ prompt.showActionMenu({
...@@ -115,11 +115,11 @@ export default { ...@@ -115,11 +115,11 @@ export default {
color: '#000000', color: '#000000',
}, },
], ],
success: function(data) { success: function(tapIndex) {
console.log('dialog success callback, click button : ' + data.tapIndex); console.log('dialog success callback, click button : ' + data.tapIndex);
}, },
fail: function(data) { fail: function(errMsg) {
console.log('dialog fail callback' + data.errMsg); console.log('dialog fail callback' + errMsg);
}, },
}); });
} }
...@@ -131,11 +131,11 @@ Describes the options for showing the toast. ...@@ -131,11 +131,11 @@ Describes the options for showing the toast.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------------------- | -------------- | --------- | ---------------------------------------- | | ------------------- | -------------- | ---- | ---------------------------------------- |
| message | string | Yes | Text to display. | | message | string | Yes | Text to display. |
| duration | number | No | Duration that the toast will remain on the screen. The default value is 1500 ms. The recommended value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used. | | duration | number | No | Duration that the toast will remain on the screen. The default value is 1500 ms. The recommended value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used.|
| bottom<sup>5+</sup> | string\|number | No | Distance between the toast frame and the bottom of the screen. | | bottom<sup>5+</sup> | string\|number | No | Distance between the toast border and the bottom of the screen. |
## Button ## Button
...@@ -143,10 +143,10 @@ Defines the prompt information of a button. ...@@ -143,10 +143,10 @@ Defines the prompt information of a button.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----- | ------ | --------- | ----------------------------- | | ----- | ------ | ---- | ------- |
| text | string | Yes | Text displayed on the button. | | text | string | Yes | Text displayed on the button.|
| color | string | Yes | Color of the button. | | color | string | Yes | Color of the button.|
## ShowDialogSuccessResponse ## ShowDialogSuccessResponse
...@@ -154,9 +154,9 @@ Defines the dialog box response result. ...@@ -154,9 +154,9 @@ Defines the dialog box response result.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----- | ------ | --------- | ----------- | | ----- | ------ | ---- | ---------- |
| index | number | Yes | Data index. | | index | number | Yes | Data index.|
## ShowDialogOptions ## ShowDialogOptions
...@@ -164,14 +164,14 @@ Describes the options for showing the dialog box. ...@@ -164,14 +164,14 @@ Describes the options for showing the dialog box.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | --------- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| title | string | No | Title of the text to display. | | title | string | No | Title of the text to display. |
| message | string | No | Text body. | | message | string | No | Text body. |
| buttons | [[Button](#button), [Button](#button)?, [Button](#button)?] | No | Array of buttons in the dialog box. The array structure is **{text:'button', color: '\#666666'}**. One to six buttons are supported. If there are more than six buttons, extra buttons will not be displayed. | | buttons | [[Button](#button), [Button](#button)?, [Button](#button)?] | No | Array of buttons in the dialog box. The array structure is **{text:'button', color: '\#666666'}**. One to six buttons are supported. If there are more than six buttons, extra buttons will not be displayed.|
| success | (data: [ShowDialogSuccessResponse](#showdialogsuccessresponse)) => void | No | Callback upon success. | | success | (data: [ShowDialogSuccessResponse](#showdialogsuccessresponse)) => void | No | Callback upon success. |
| cancel | (data: string, code: string) => void | No | Callback upon failure. | | cancel | (data: string, code: string) => void | No | Callback upon failure. |
| complete | (data: string) => void | No | Called when the API call is complete. | | complete | (data: string) => void | No | Called when the API call is complete. |
## ShowActionMenuOptions<sup>6+</sup> ## ShowActionMenuOptions<sup>6+</sup>
...@@ -179,10 +179,10 @@ Describes the options for showing the action menu. ...@@ -179,10 +179,10 @@ Describes the options for showing the action menu.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | --------- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| title | string | No | Title of the text to display. | | title | string | No | Title of the text to display. |
| buttons | [[Button](#button), [Button](#button)?, [Button](#button)?, [Button](#button)?, [Button](#button)?, [Button](#button)?] | Yes | Array of buttons in the dialog box. The array structure is **{text:'button', color: '\#666666'}**. One to six buttons are supported. | | buttons | [[Button](#button), [Button](#button)?, [Button](#button)?, [Button](#button)?, [Button](#button)?, [Button](#button)?] | Yes | Array of buttons in the dialog box. The array structure is **{text:'button', color: '\#666666'}**. One to six buttons are supported.|
| success | (tapIndex: number, errMsg: string) => void | No | Invoked when a dialog box is displayed. | | success | (tapIndex: number, errMsg: string) => void | No | Invoked when a dialog box is displayed. |
| fail | (errMsg: string) => void | No | Callback upon failure. | | fail | (errMsg: string) => void | No | Callback upon failure. |
| complete | (data: string) => void | No | Invoked when a dialog box is closed. | | complete | (data: string) => void | No | Invoked when a dialog box is closed. |
# Page Routing # Page Routing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
> >
> - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.router`](js-apis-router.md) instead. > - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.router`](js-apis-router.md) instead.
> >
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
## Modules to Import ## Modules to Import
``` ```js
import router from '@system.router'; import router from '@system.router';
``` ```
...@@ -31,7 +31,7 @@ Navigates to a specified page in the application. ...@@ -31,7 +31,7 @@ Navigates to a specified page in the application.
**Example** **Example**
``` ```js
// Current page // Current page
export default { export default {
pushPage() { pushPage() {
...@@ -49,7 +49,7 @@ export default { ...@@ -49,7 +49,7 @@ export default {
``` ```
``` ```js
// routerpage2 page // routerpage2 page
export default { export default {
data: { data: {
...@@ -85,7 +85,7 @@ Replaces the current page with another one in the application and destroys the c ...@@ -85,7 +85,7 @@ Replaces the current page with another one in the application and destroys the c
**Example** **Example**
``` ```js
// Current page // Current page
export default { export default {
replacePage() { replacePage() {
...@@ -100,7 +100,7 @@ export default { ...@@ -100,7 +100,7 @@ export default {
``` ```
``` ```js
// detail page // detail page
export default { export default {
data: { data: {
...@@ -128,7 +128,7 @@ Returns to the previous page or a specified page. ...@@ -128,7 +128,7 @@ Returns to the previous page or a specified page.
**Example** **Example**
``` ```js
// index page // index page
export default { export default {
indexPushPage() { indexPushPage() {
...@@ -140,7 +140,7 @@ export default { ...@@ -140,7 +140,7 @@ export default {
``` ```
``` ```js
// detail page // detail page
export default { export default {
detailPushPage() { detailPushPage() {
...@@ -152,7 +152,7 @@ export default { ...@@ -152,7 +152,7 @@ export default {
``` ```
``` ```js
// Navigate from the mall page to the detail page through router.back(). // Navigate from the mall page to the detail page through router.back().
export default { export default {
mallBackPage() { mallBackPage() {
...@@ -162,7 +162,7 @@ export default { ...@@ -162,7 +162,7 @@ export default {
``` ```
``` ```js
// Navigate from the detail page to the index page through router.back(). // Navigate from the detail page to the index page through router.back().
export default { export default {
defaultBack() { defaultBack() {
...@@ -172,7 +172,7 @@ export default { ...@@ -172,7 +172,7 @@ export default {
``` ```
``` ```js
// Return to the detail page through router.back(). // Return to the detail page through router.back().
export default { export default {
backToDetail() { backToDetail() {
...@@ -208,7 +208,7 @@ Clears all historical pages in the stack and retains only the current page at th ...@@ -208,7 +208,7 @@ Clears all historical pages in the stack and retains only the current page at th
**Example** **Example**
``` ```js
export default { export default {
clearPage() { clearPage() {
router.clear(); router.clear();
...@@ -232,7 +232,7 @@ Obtains the number of pages in the current stack. ...@@ -232,7 +232,7 @@ Obtains the number of pages in the current stack.
**Example** **Example**
``` ```js
export default { export default {
getLength() { getLength() {
var size = router.getLength(); var size = router.getLength();
...@@ -257,7 +257,7 @@ Obtains state information about the current page. ...@@ -257,7 +257,7 @@ Obtains state information about the current page.
**Example** **Example**
``` ```js
export default { export default {
getState() { getState() {
var page = router.getState(); var page = router.getState();
...@@ -284,7 +284,7 @@ Enables the display of a confirm dialog box before returning to the previous pag ...@@ -284,7 +284,7 @@ Enables the display of a confirm dialog box before returning to the previous pag
**Example** **Example**
``` ```js
export default { export default {
enableAlertBeforeBackPage() { enableAlertBeforeBackPage() {
router.enableAlertBeforeBackPage({ router.enableAlertBeforeBackPage({
...@@ -292,8 +292,8 @@ export default { ...@@ -292,8 +292,8 @@ export default {
success: function() { success: function() {
console.log('success'); console.log('success');
}, },
fail: function() { cancel: function() {
console.log('fail'); console.log('cancel');
}, },
}); });
} }
...@@ -316,15 +316,15 @@ Disables the display of a confirm dialog box before returning to the previous pa ...@@ -316,15 +316,15 @@ Disables the display of a confirm dialog box before returning to the previous pa
**Example** **Example**
``` ```js
export default { export default {
disableAlertBeforeBackPage() { disableAlertBeforeBackPage() {
router.disableAlertBeforeBackPage({ router.disableAlertBeforeBackPage({
success: function() { success: function() {
console.log('success'); console.log('success');
}, },
fail: function() { cancel: function() {
console.log('fail'); console.log('cancel');
}, },
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册