diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 029f412c42188161bb10e73159c867137a9ffac4..87e2bda0fe1883722417ab38523d266e87ef168e 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -1,4 +1,4 @@ -# 接口 +# 接口 - [开发说明](development-intro.md) - Ability框架 - FA模型 @@ -91,8 +91,10 @@ - bundle/[PackInfo (PackInfo)](js-apis-bundle-PackInfo.md) - UI界面 - [@ohos.animator (动画)](js-apis-animator.md) + - [@ohos.curves (插值计算)](js-apis-curve.md) + - [@ohos.matrix4 (矩阵变换)](js-apis-matrix4.md) - [@ohos.mediaquery (媒体查询)](js-apis-mediaquery.md) - - [@ohos.prompt (弹窗)](js-apis-prompt.md) + - [@ohos.promptAction (弹窗)](js-apis-promptAction.md) - [@ohos.router (页面路由)](js-apis-router.md) - [@ohos.uiAppearance(用户界面外观)](js-apis-uiappearance.md) - 图形图像 @@ -266,6 +268,7 @@ - 已停止维护的接口 - [@ohos.bytrace (性能打点)](js-apis-bytrace.md) - [@ohos.data.storage (轻量级存储)](js-apis-data-storage.md) + - [@ohos.prompt (弹窗)](js-apis-prompt.md) - [@system.app (应用上下文)](js-apis-system-app.md) - [@system.battery (电量信息)](js-apis-system-battery.md) - [@system.bluetooth (蓝牙)](js-apis-system-bluetooth.md) diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001118642902.png b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001118642902.png new file mode 100644 index 0000000000000000000000000000000000000000..36eab44e87c075e01baa66bfc48a86ba703b7835 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001118642902.png differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001174104410.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001174104410.gif new file mode 100644 index 0000000000000000000000000000000000000000..df8e47d8359338f9d0412cacfe12b847c28c2a84 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001174104410.gif differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001174422898.png b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001174422898.png new file mode 100644 index 0000000000000000000000000000000000000000..1dc7d8d7beda862221b05a9247723a3f74bf323d Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001174422898.png differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219662645.png b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219662645.png new file mode 100644 index 0000000000000000000000000000000000000000..747b8f915f2d40803ce6a7937de1add5deb8e640 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219662645.png differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219744181.png b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219744181.png new file mode 100644 index 0000000000000000000000000000000000000000..605c0a1ddc0e2bace2e4c9a23fc2391af9ebf5bf Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219744181.png differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219864131.png b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219864131.png new file mode 100644 index 0000000000000000000000000000000000000000..5c0ada67867ec3765eeb53af5c62369762d0bac4 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219864131.png differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219864133.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219864133.gif new file mode 100644 index 0000000000000000000000000000000000000000..0befd736af77db15c203c4a5578929baf1d83e08 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219864133.gif differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_00007.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_00007.gif new file mode 100644 index 0000000000000000000000000000000000000000..8c43bdf5b331963459154d4f0400fad7b17b34e8 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_00007.gif differ diff --git a/zh-cn/application-dev/reference/apis/js-apis-animator.md b/zh-cn/application-dev/reference/apis/js-apis-animator.md index 54966570a6c4af2578a2dc3d250edd033c4cba16..6689361e739a8a6746f1a6fe98b7f19b70977cbb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-animator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-animator.md @@ -12,17 +12,16 @@ ```js import animator from '@ohos.animator'; ``` +## create9+ - -## createAnimator - -createAnimator(options: AnimatorOptions): AnimatorResult +create(options: AnimatorOptions): AnimatorResult 定义Animator类。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ----------------------------------- | ---- | ------- | | options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。 | @@ -34,73 +33,67 @@ createAnimator(options: AnimatorOptions): AnimatorResult **示例:** - ```html - -
-
-
-
- ``` - ```js - // js - export default { - data : { - divWidth: 200, - divHeight: 200, - animator: null - }, - onInit() { - var options = { - duration: 1500, - easing: 'friction', - fill: 'forwards', - iterations: 2, - begin: 200.0, - end: 400.0 - }; - this.animator = animator.createAnimator(options); - }, - Show() { - var options1 = { - duration: 2000, - easing: 'friction', - fill: 'forwards', - iterations: 1, - begin: 200.0, - end: 400.0 - }; - this.animator.update(options1); - var _this = this; - this.animator.onframe = function(value) { - _this.divWidth = value; - _this.divHeight = value; - }; - this.animator.play(); - } - } + var options = { + duration: 1500, + easing: 'friction', + delay: 0, + fill: 'forwards', + direction: "normal", + iterations: 3, + begin: 200.0, + end: 400.0, + }; + animator.create(options); ``` ## AnimatorResult 定义Animator结果接口。 -### update + -update(options: AnimatorOptions): void +### reset9+ + +reset(options: AnimatorOptions): void 更新当前动画器。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ----------------------------------- | ---- | ------- | | options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。 | +**错误码:** + +以下错误码的详细介绍请参见[ohos.animator(动画)](../errorcodes/errorcode-animator.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + + **示例:** + ```js -animator.update(options); +var options = { + duration: 1500, + easing: 'friction', + delay: 0, + fill: 'forwards', + direction: "normal", + iterations: 3, + begin: 200.0, + end: 400.0, +}; +try { + animator.reset(options); +} catch(error) { + console.error(`Animator reset failed, error code: ${error.code}, message: ${error.message}.`); +} ``` ### play @@ -112,6 +105,7 @@ play(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.play(); ``` @@ -125,6 +119,7 @@ finish(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.finish(); ``` @@ -138,6 +133,7 @@ pause(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.pause(); ``` @@ -151,6 +147,7 @@ cancel(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.cancel(); ``` @@ -164,6 +161,7 @@ reverse(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.reverse(); ``` @@ -177,11 +175,13 @@ onframe: (progress: number) => void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | -------- | | progress | number | 是 | 动画的当前进度。 | **示例:** + ```js animator.onframe(); ``` @@ -195,6 +195,7 @@ onfinish: () => void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.onfinish(); ``` @@ -202,12 +203,13 @@ animator.onfinish(); ### oncancel oncancel: () => void - +不再维护 动画被取消时回调。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.oncancel(); ``` @@ -221,10 +223,13 @@ onrepeat: () => void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.onrepeat(); ``` + + ## AnimatorOptions 定义动画选项。 @@ -241,3 +246,122 @@ animator.onrepeat(); | iterations | number | 是 | 动画播放次数,默认值1。设置为0时不播放,设置为-1时无限次播放。 | | begin | number | 是 | 动画插值起点,默认为0。 | | end | number | 是 | 动画插值终点,默认为1。 | + + +## 完整示例 + +```html + +
+
+
+
+``` + +```js +export default { + data: { + divWidth: 200, + divHeight: 200, + animator: null + }, + onInit() { + var options = { + duration: 1500, + easing: 'friction', + delay: 0, + fill: 'forwards', + direction: "normal", + iterations: 2, + begin: 200.0, + end: 400.0 + }; + this.animator = animator.create(options); + }, + Show() { + var options1 = { + duration: 1500, + easing: 'friction', + delay: 0, + fill: 'forwards', + direction: "normal", + iterations: 2, + begin: 0, + end: 400.0, + }; + try { + this.animator.reset(options1); + } catch(error) { + console.error(`Animator reset failed, error code: ${error.code}, message: ${error.message}.`); + } + var _this = this; + this.animator.onframe = function(value) { + _this.divWidth = value; + _this.divHeight = value; + }; + this.animator.play(); + } +} +``` + + ![zh-cn_image_00007](figures/zh-cn_image_00007.gif) + +## update(deprecated) + +update(options: AnimatorOptions): void + +更新当前动画器。 + +从API version9开始不再维护,建议使用[reset9+](#reset9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------------- | ---- | ------- | +| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。 | + +**示例:** + +```js +animator.update(options); +``` + +## createAnimator(deprecated) + +createAnimator(options: AnimatorOptions): AnimatorResult + +定义Animator类。 + +从API version9开始不再维护,建议使用[create9+](#create9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------------- | ---- | ------- | +| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------------------- | ------------- | +| [AnimatorResult](#animatorresult) | Animator结果接口。 | + +**示例:** + +```js +var options = { + duration: 1500, + easing: 'friction', + delay: 0, + fill: 'forwards', + direction: "normal", + iterations: 3, + begin: 200.0, + end: 400.0, +}; +this.animator = animator.createAnimator(options); +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-interpolation-calculation.md b/zh-cn/application-dev/reference/apis/js-apis-curve.md similarity index 89% rename from zh-cn/application-dev/reference/arkui-ts/ts-interpolation-calculation.md rename to zh-cn/application-dev/reference/apis/js-apis-curve.md index f12674493dd658953d876d3f2094ce36e5a5c905..4dc69624440e229b6bce9e312941581ba965454e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-interpolation-calculation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-curve.md @@ -1,9 +1,10 @@ # 插值计算 -设置动画插值曲线,用于构造阶梯曲线对象、构造三阶贝塞尔曲线对象和构造弹簧曲线对象。 +本模块提供设置动画插值曲线功能,用于构造阶梯曲线对象、构造三阶贝塞尔曲线对象和构造弹簧曲线对象。 > **说明:** -> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> 本模块首批接口从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 导入模块 @@ -20,11 +21,13 @@ initCurve(curve?: Curve):ICurve 插值曲线的初始化函数,可以根据入参创建一个插值曲线对象。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 默认值 | 说明 | | ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- | -| curve | [Curve](ts-appendix-enums.md#curve) | 否 | Curve.Linear | 曲线类型。 | +| curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | 否 | Curve.Linear | 曲线类型。 | **返回值:** @@ -48,6 +51,8 @@ stepsCurve(count: number, end: boolean):ICurve 构造阶梯曲线对象。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -77,6 +82,7 @@ cubicBezierCurve(x1: number, y1: number, x2: number, y2: number):ICurve 构造三阶贝塞尔曲线对象,曲线的值必须处于0-1之间。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -108,6 +114,7 @@ springCurve(velocity: number, mass: number, stiffness: number, damping: number) 构造弹簧曲线对象。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -143,6 +150,8 @@ interpolate(fraction: number): number 插值曲线的插值计算函数,可以通过传入的归一化时间参数返回当前的插值 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -171,11 +180,13 @@ init(curve?: Curve): string 插值曲线的初始化函数,可以根据入参创建一个插值曲线对象,从API version9开始废弃,推荐使用[Curves.initCurve](#curvesinitcurve9)。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 默认值 | 说明 | | ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- | -| curve |[Curve](ts-appendix-enums.md#curve) | 否 | Curve.Linear | 曲线类型。 | +| curve |[Curve](../arkui-ts/ts-appendix-enums.md#curve) | 否 | Curve.Linear | 曲线类型。 | ## Curves.steps(deprecated) @@ -185,6 +196,8 @@ steps(count: number, end: boolean): string 构造阶梯曲线对象,从API version9开始废弃,推荐使用[Curves. stepsCurve](# curvesstepscurve9)。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -200,6 +213,7 @@ cubicBezier(x1: number, y1: number, x2: number, y2: number): string 构造三阶贝塞尔曲线对象,曲线的值必须处于0-1之间,API version9开始废弃,推荐使用 [Curves.cubicBezierCurve](#curvescubicbeziercurve9)。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -217,6 +231,8 @@ spring(velocity: number, mass: number, stiffness: number, damping: number): stri 构造弹簧曲线对象,从API version9开始废弃,推荐使用[Curves.springCurve](#curvesspringcurve9)。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md b/zh-cn/application-dev/reference/apis/js-apis-matrix4.md similarity index 93% rename from zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md rename to zh-cn/application-dev/reference/apis/js-apis-matrix4.md index 43d8e5b727ca19041f0c4f9cfdfdfcae59e3f8a6..a53809173e6b63a26bfe5768a870991171ac22e7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-matrix4.md @@ -1,10 +1,10 @@ # 矩阵变换 -可对图形进行平移、旋转和缩放等。 +本模块提供矩阵变换功能,可对图形进行平移、旋转和缩放等。 > **说明:** > -> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> 本模块首批接口从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 导入模块 @@ -21,6 +21,8 @@ init(array: Array<number>): Matrix4Transit Matrix的构造函数,可以通过传入的参数创建一个四阶矩阵,矩阵为列优先。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -85,6 +87,8 @@ identity(): Matrix4Transit Matrix的初始化函数,可以返回一个单位矩阵对象。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **返回值:** | 类型 | 说明 | @@ -128,6 +132,8 @@ copy(): Matrix4Transit Matrix的拷贝函数,可以拷贝一份当前的矩阵对象。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **返回值:** | 类型 | 说明 | @@ -174,6 +180,8 @@ combine(matrix: Matrix4): Matrix4Transit Matrix的叠加函数,可以将两个矩阵的效果叠加起来生成一个新的矩阵对象。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -222,9 +230,10 @@ struct Test { invert(): Matrix4Transit - Matrix的逆函数,可以返回一个当前矩阵对象的逆矩阵,即效果正好相反。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **返回值:** | 类型 | 说明 | @@ -263,9 +272,10 @@ struct Tests { translate({x?: number, y?: number, z?: number}): Matrix4Transit - Matrix的平移函数,可以为当前矩阵增加x轴/Y轴/Z轴平移效果。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -310,6 +320,8 @@ scale({x?: number, y?: number, z?: number, centerX?: number, centerY?: number}): Matrix的缩放函数,可以为当前矩阵增加x轴/Y轴/Z轴缩放效果。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -356,6 +368,8 @@ rotate({x?: number, y?: number, z?: number, angle?: number, centerX?: Length, ce Matrix的旋转函数,可以为当前矩阵增加x轴/Y轴/Z轴旋转效果。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -403,6 +417,8 @@ transformPoint(point: Point): Point Matrix的坐标点转换函数,可以将当前的变换效果作用到一个坐标点上。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-prompt.md b/zh-cn/application-dev/reference/apis/js-apis-prompt.md index 0553da25895103c1ada4a4ce65bd56e3cebaf53e..b757e22f002c9b512580c886f4371ad1a56cbc7f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-prompt.md +++ b/zh-cn/application-dev/reference/apis/js-apis-prompt.md @@ -3,7 +3,8 @@ 创建并显示文本提示框、对话框和操作菜单。 > **说明:** -> +> 从API Version 9 开始,该接口不再维护,推荐使用新接口[@ohos.promptAction (弹窗)](js-apis-promptAction.md) +> > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -45,7 +46,7 @@ prompt.showToast({ | 名称 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| message | string\| [Resource](../../ui/ts-types.md#resource类型)9+ | 是 | 显示的文本信息。 | +| message | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 是 | 显示的文本信息。 | | duration | number | 否 | 默认值1500ms,取值区间:1500ms-10000ms。若小于1500ms则取默认值,若大于10000ms则取上限值10000ms。 | | bottom | string\| number | 否 | 设置弹窗边框距离屏幕底部的位置。 | @@ -146,8 +147,8 @@ prompt.showDialog({ | 名称 | 类型 | 必填 | 说明 | | ------- | ---------------------------------------- | ---- | ---------------------------------------- | -| title | string\| [Resource](../../ui/ts-types.md#resource类型)9+ | 否 | 标题文本。 | -| message | string\| [Resource](../../ui/ts-types.md#resource类型)9+ | 否 | 内容文本。 | +| title | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 否 | 标题文本。 | +| message | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 否 | 内容文本。 | | buttons | Array | 否 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。 | ## ShowDialogSuccessResponse @@ -255,7 +256,7 @@ prompt.showActionMenu({ | 名称 | 类型 | 必填 | 说明 | | ------- | ---------------------------------------- | ---- | ---------------------------------------- | -| title | string\| [Resource](../../ui/ts-types.md#resource类型)9+ | 否 | 标题文本。 | +| title | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 否 | 标题文本。 | | buttons | Array<[Button](#button)> | 是 | 菜单中菜单项按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | ## ActionMenuSuccessResponse @@ -276,6 +277,6 @@ prompt.showActionMenu({ | 名称 | 类型 | 必填 | 说明 | | ----- | ---------------------------------------- | ---- | ------- | -| text | string\| [Resource](../../ui/ts-types.md#resource类型)9+ | 是 | 按钮文本内容。 | -| color | string\| [Resource](../../ui/ts-types.md#resource类型)9+ | 是 | 按钮文本颜色。 | +| text | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 是 | 按钮文本内容。 | +| color | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 是 | 按钮文本颜色。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-promptAction.md b/zh-cn/application-dev/reference/apis/js-apis-promptAction.md new file mode 100644 index 0000000000000000000000000000000000000000..af1d690e2d349dc7625d64d130005c9e454492a0 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-promptAction.md @@ -0,0 +1,341 @@ +# 弹窗 + +创建并显示文本提示框、对话框和操作菜单。 + +> **说明:** +> +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```js +import promptAction from '@ohos.promptAction' +``` + +## promptAction.showToast + +showToast(options: ShowToastOptions): void + +创建并显示文本提示框。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------------- | ---- | ------- | +| options | [ShowToastOptions](#showtoastoptions) | 是 | 文本弹窗选项。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + +**示例:** + +```js +try { + promptAction.showToast({ + message: 'Message Info', + duration: 2000, + }); +} catch (error) { + console.error(`showToast args error code is ${error.code}, message is ${error.message}`); +}; + +``` + +![zh-cn_image_0001](figures/zh-cn_image_0001.gif) + +## ShowToastOptions + +文本提示框的选项。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full。 + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| message | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 是 | 显示的文本信息。 | +| duration | number | 否 | 默认值1500ms,取值区间:1500ms-10000ms。若小于1500ms则取默认值,若大于10000ms则取上限值10000ms。 | +| bottom | string\| number | 否 | 设置弹窗边框距离屏幕底部的位置。 | + +## promptAction.showDialog + +showDialog(options: ShowDialogOptions): Promise<ShowDialogSuccessResponse> + +创建并显示对话框,对话框响应后同步返回结果。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------------------- | ---- | ------ | +| options | [ShowDialogOptions](#showdialogoptions) | 是 | 对话框选项。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------- | -------- | +| Promise<[ShowDialogSuccessResponse](#showdialogsuccessresponse)> | 对话框响应结果。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + +**示例:** + +```js +try { + promptAction.showDialog({ + title: 'Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000', + }, + { + text: 'button2', + color: '#000000', + } + ], + }) + .then(data => { + console.info('showDialog success, click button: ' + data.index); + }) + .catch(err => { + console.info('showDialog error: ' + err); + }) +} catch (error) { + console.error(`showDialog args error code is ${error.code}, message is ${error.message}`); +}; +``` + +![zh-cn_image_0002](figures/zh-cn_image_0002.gif) + +## promptAction.showDialog + +showDialog(options: ShowDialogOptions, callback: AsyncCallback<ShowDialogSuccessResponse>):void + +创建并显示对话框,对话框响应结果异步返回。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------ | +| options | [ShowDialogOptions](#showdialogoptions) | 是 | 页面显示对话框信息描述。 | +| callback | AsyncCallback<[ShowDialogSuccessResponse](#showdialogsuccessresponse)> | 是 | 对话框响应结果回调。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + +**示例:** + +```js +try { + promptAction.showDialog({ + title: 'showDialog Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000', + }, + { + text: 'button2', + color: '#000000', + } + ] + }, (err, data) => { + if (err) { + console.info('showDialog err: ' + err); + return; + } + console.info('showDialog success callback, click button: ' + data.index); + }); +} catch (error) { + console.error(`showDialog args error code is ${error.code}, message is ${error.message}`); +}; +``` + +![zh-cn_image_0002](figures/zh-cn_image_0002.gif) + +## ShowDialogOptions + +对话框的选项。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ---------------------------------------- | +| title | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 否 | 标题文本。 | +| message | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 否 | 内容文本。 | +| buttons | Array | 否 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。 | + +## ShowDialogSuccessResponse + +对话框的响应结果。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 说明 | +| ----- | ------ | ------------------- | +| index | number | 选中按钮在buttons数组中的索引。 | + +## promptAction.showActionMenu + +showActionMenu(options: ActionMenuOptions, callback: AsyncCallback<ActionMenuSuccessResponse>):void + +创建并显示操作菜单,菜单响应结果异步返回。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | --------- | +| options | [ActionMenuOptions](#actionmenuoptions) | 是 | 操作菜单选项。 | +| callback | AsyncCallback<[ActionMenuSuccessResponse](#actionmenusuccessresponse)> | 是 | 菜单响应结果回调。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + +**示例:** + +```js +try { + promptAction.showActionMenu({ + title: 'Title Info', + buttons: [ + { + text: 'item1', + color: '#666666', + }, + { + text: 'item2', + color: '#000000', + }, + ] + }, (err, data) => { + if (err) { + console.info('showActionMenu err: ' + err); + return; + } + console.info('showActionMenu success callback, click button: ' + data.index); + }) +} catch (error) { + console.error(`showActionMenu args error code is ${error.code}, message is ${error.message}`); +}; +``` + +![zh-cn_image_0005](figures/zh-cn_image_0005.gif) + +## promptAction.showActionMenu + +showActionMenu(options: ActionMenuOptions): Promise<ActionMenuSuccessResponse> + +创建并显示操作菜单,菜单响应后同步返回结果。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------------------- | ---- | ------- | +| options | [ActionMenuOptions](#actionmenuoptions) | 是 | 操作菜单选项。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------- | ------- | +| Promise<[ActionMenuSuccessResponse](#actionmenusuccessresponse)> | 菜单响应结果。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + +**示例:** + +```js +try { + promptAction.showActionMenu({ + title: 'showActionMenu Title Info', + buttons: [ + { + text: 'item1', + color: '#666666', + }, + { + text: 'item2', + color: '#000000', + }, + ] + }) + .then(data => { + console.info('showActionMenu success, click button: ' + data.index); + }) + .catch(err => { + console.info('showActionMenu error: ' + err); + }) +} catch (error) { + console.error(`showActionMenu args error code is ${error.code}, message is ${error.message}`); +}; +``` + +![zh-cn_image_0005](figures/zh-cn_image_0005.gif) + +## ActionMenuOptions + +操作菜单的选项。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full。 + +| 名称 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ---------------------------------------- | +| title | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 否 | 标题文本。 | +| buttons | Array<[Button](#button)> | 是 | 菜单中菜单项按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | + +## ActionMenuSuccessResponse + +操作菜单的响应结果。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ------------------------ | +| index | number | 否 | 选中按钮在buttons数组中的索引,从0开始。 | + +## Button + +菜单中的菜单项按钮。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 必填 | 说明 | +| ----- | ---------------------------------------- | ---- | ------- | +| text | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 是 | 按钮文本内容。 | +| color | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 是 | 按钮文本颜色。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-router.md b/zh-cn/application-dev/reference/apis/js-apis-router.md index 4735f20e7e94bd8013e93f0b3bca3b9ca21a608e..2a7401953f2f3442039ab871b698bf9f58eb5099 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-router.md +++ b/zh-cn/application-dev/reference/apis/js-apis-router.md @@ -14,108 +14,403 @@ import router from '@ohos.router' ``` -## router.push +## router.pushUrl9+ -push(options: RouterOptions): void +pushUrl(options: RouterOptions): Promise<void> 跳转到应用内的指定页面。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | --------- | | options | [RouterOptions](#routeroptions) | 是 | 跳转页面描述信息。 | +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------- | +| Promise<void> | 异常返回结果 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 100002 | Uri error. The uri of router is not exist. | +| 100003 | Page stack error. The pages are pushed too much. | **示例:** + ```js -router.push({ - url: 'pages/routerpage2', - params: { - data1: 'message', - data2: { - data3: [123, 456, 789] +try { + router.pushUrl({ + url: 'pages/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, }, - }, -}); + }) + .then(() => { + // success + }) + .catch(err => { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + }) +} catch (error) { + console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`); +}; ``` -## router.push9+ -push(options: RouterOptions, mode: RouterMode): void +## router.pushUrl9+ + +pushUrl(options: RouterOptions, callback: AsyncCallback<void>): void 跳转到应用内的指定页面。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | --------- | +| options | [RouterOptions](#routeroptions) | 是 | 跳转页面描述信息。 | +| callback | AsyncCallback<void> | 是 | 异常响应回调 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 100002 | Uri error. The uri of router is not exist. | +| 100003 | Page stack error. The pages are pushed too much. | + +**示例:** + +```js +try { + router.pushUrl({ + url: 'pages/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, + }, + }, (err) => { + if (err) { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('pushUrl success'); + }); +} catch (error) { + console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`); +}; +``` +## router.pushUrl9+ + +pushUrl(options: RouterOptions, mode: RouterMode): Promise<void> + +跳转到应用内的指定页面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ---------- | | options | [RouterOptions](#routeroptions) | 是 | 跳转页面描述信息。 | | mode | [RouterMode](#routermode9) | 是 | 跳转页面使用的模式。 | +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------- | +| Promise<void> | 异常返回结果 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 100002 | Uri error. The uri of router is not exist. | +| 100003 | Page stack error. The pages are pushed too much. | **示例:** + ```js -router.push({ - url: 'pages/routerpage2/routerpage2', - params: { - data1: 'message', - data2: { - data3: [123, 456, 789] +try { + router.pushUrl({ + url: 'pages/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, }, - }, -},router.RouterMode.Standard); + }, router.RouterMode.Standard) + .then(() => { + // success + }) + .catch(err => { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + }) +} catch (error) { + console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`); +}; ``` -## router.replace +## router.pushUrl9+ -replace(options: RouterOptions): void +pushUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback<void>): void -用应用内的某个页面替换当前页面,并销毁被替换的页面。 +跳转到应用内的指定页面。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ---------- | +| options | [RouterOptions](#routeroptions) | 是 | 跳转页面描述信息。 | +| mode | [RouterMode](#routermode9) | 是 | 跳转页面使用的模式。 | +| callback | AsyncCallback<void> | 是 | 异常响应回调 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 100002 | Uri error. The uri of router is not exist. | +| 100003 | Page stack error. The pages are pushed too much. | + +**示例:** + +```js +try { + router.pushUrl({ + url: 'pages/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, + }, + }, router.RouterMode.Standard, (err) => { + if (err) { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('pushUrl success'); + }); +} catch (error) { + console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`); +}; +``` + +## router.replaceUrl9+ + +replaceUrl(options: RouterOptions): Promise<void> + +用应用内的某个页面替换当前页面,并销毁被替换的页面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite + +**参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ------------------ | | options | [RouterOptions](#routeroptions) | 是 | 替换页面描述信息。 | +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------- | +| Promise<void> | 异常返回结果 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 200002 | Uri error. The uri of router is not exist. | + **示例:** ```js -router.replace({ - url: 'pages/detail', - params: { - data1: 'message', - }, -}); +try { + router.replaceUrl({ + url: 'pages/detail', + params: { + data1: 'message', + }, + }) + .then(() => { + // success + }) + .catch(err => { + console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); + }) +} catch (error) { + console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`); +}; ``` - ## router.replace9+ +## router.replaceUrl9+ -replace(options: RouterOptions, mode: RouterMode): void +replaceUrl(options: RouterOptions, callback: AsyncCallback<void>): void 用应用内的某个页面替换当前页面,并销毁被替换的页面。 -**系统能力:** SystemCapability.ArkUI.ArkUI.Full +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite **参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ------------------ | +| options | [RouterOptions](#routeroptions) | 是 | 替换页面描述信息。 | +| callback | AsyncCallback<void> | 是 | 异常响应回调 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 200002 | Uri error. The uri of router is not exist. | + +**示例:** + +```js +try { + router.replaceUrl({ + url: 'pages/detail', + params: { + data1: 'message', + }, + }, (err) => { + if (err) { + console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('replaceUrl success'); + }); +} catch (error) { + console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`); +}; +``` + +## router.replaceUrl9+ + +replaceUrl(options: RouterOptions, mode: RouterMode): Promise<void> + +用应用内的某个页面替换当前页面,并销毁被替换的页面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite + +**参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ---------- | | options | [RouterOptions](#routeroptions) | 是 | 替换页面描述信息。 | | mode | [RouterMode](#routermode9) | 是 | 跳转页面使用的模式。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------- | +| Promise<void> | 异常返回结果 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 200002 | Uri error. The uri of router is not exist. | + **示例:** ```js -router.replace({ - url: 'pages/detail/detail', - params: { - data1: 'message', - }, -}, router.RouterMode.Standard); +try { + router.replaceUrl({ + url: 'pages/detail', + params: { + data1: 'message', + }, + }, router.RouterMode.Standard) + .then(() => { + // success + }) + .catch(err => { + console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); + }) +} catch (error) { + console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`); +}; +``` + +## router.replaceUrl9+ + +replaceUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback<void>): void + +用应用内的某个页面替换当前页面,并销毁被替换的页面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ---------- | +| options | [RouterOptions](#routeroptions) | 是 | 替换页面描述信息。 | +| mode | [RouterMode](#routermode9) | 是 | 跳转页面使用的模式。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 200002 | Uri error. The uri of router is not exist. | + +**示例:** + +```js +try { + router.replaceUrl({ + url: 'pages/detail', + params: { + data1: 'message', + }, + }, router.RouterMode.Standard, (err) => { + if (err) { + console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('replaceUrl success'); + }); +} catch (error) { + console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`); +}; ``` ## router.back @@ -127,6 +422,7 @@ back(options?: RouterOptions ): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ------------------------------------------------------------ | | options | [RouterOptions](#routeroptions) | 否 | 返回页面描述信息,其中参数url指路由跳转时会返回到指定url的界面,如果页面栈上没有url页面,则不响应该情况。如果url未设置,则返回上一页,页面栈里面的page不会回收,出栈后会被回收。 | @@ -160,11 +456,13 @@ getLength(): string **系统能力:** SystemCapability.ArkUI.ArkUI.Full **返回值:** + | 类型 | 说明 | | ------ | ------------------ | | string | 页面数量,页面栈支持最大数值是32。 | **示例:** + ```js var size = router.getLength(); console.log('pages stack size = ' + size); @@ -205,25 +503,38 @@ console.log('current path = ' + page.path); | name | string | 表示当前页面的名称,即对应文件名。 | | path | string | 表示当前页面的路径。 | -## router.enableAlertBeforeBackPage +## router.enableBackPageAlert9+ -enableAlertBeforeBackPage(options: EnableAlertOptions): void +enableBackPageAlert(options: EnableAlertOptions): void 开启页面返回询问对话框。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ---------------------------------------- | ---- | --------- | | options | [EnableAlertOptions](#enablealertoptions) | 是 | 文本弹窗信息描述。 | +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + **示例:** - ```js - router.enableAlertBeforeBackPage({ + ```js +try { + router.enableBackPageAlert({ message: 'Message Info' - }); + }); +} catch(error) { + console.error(`enableBackPageAlert failed, code is ${error.code}, message is ${error.message}`); +} ``` ## EnableAlertOptions @@ -244,6 +555,7 @@ disableAlertBeforeBackPage(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js router.disableAlertBeforeBackPage(); ``` @@ -400,4 +712,145 @@ struct Second { .height('100%') } } -``` \ No newline at end of file +``` + +## router.push(deprecated) + +push(options: RouterOptions): void + +跳转到应用内的指定页面。 + +从API version9开始不再维护,建议使用[pushUrl9+](#routerpushurl9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | --------- | +| options | [RouterOptions](#routeroptions) | 是 | 跳转页面描述信息。 | + + +**示例:** + +```js +router.push({ + url: 'pages/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, + }, +}); +``` +## router.push(deprecated) + +push(options: RouterOptions, mode: RouterMode): void + +跳转到应用内的指定页面。 + +从API version9开始不再维护,建议使用[pushUrl9+](#routerpushurl9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ---------- | +| options | [RouterOptions](#routeroptions) | 是 | 跳转页面描述信息。 | +| mode | [RouterMode](#routermode9) | 是 | 跳转页面使用的模式。 | + + +**示例:** + +```js +router.push({ + url: 'pages/routerpage2/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, + }, +},router.RouterMode.Standard); +``` + +## router.replace(deprecated) + +replace(options: RouterOptions): void + +用应用内的某个页面替换当前页面,并销毁被替换的页面。 + +从API version9开始不再维护,建议使用[replaceUrl9+](#routerreplaceurl9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ------------------ | +| options | [RouterOptions](#routeroptions) | 是 | 替换页面描述信息。 | + +**示例:** + +```js +router.replace({ + url: 'pages/detail', + params: { + data1: 'message', + }, +}); +``` + + ## router.replace(deprecated) + +replace(options: RouterOptions, mode: RouterMode): void + +用应用内的某个页面替换当前页面,并销毁被替换的页面。 + +从API version9开始不再维护,建议使用[replaceUrl9+](#routerreplaceurl9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ---------- | +| options | [RouterOptions](#routeroptions) | 是 | 替换页面描述信息。 | +| mode | [RouterMode](#routermode9) | 是 | 跳转页面使用的模式。 | + +**示例:** + +```js +router.replace({ + url: 'pages/detail/detail', + params: { + data1: 'message', + }, +}, router.RouterMode.Standard); +``` + +## router.enableAlertBeforeBackPage(deprecated) + +enableAlertBeforeBackPage(options: EnableAlertOptions): void + +开启页面返回询问对话框。 + +从API version9开始不再维护,建议使用[enableBackPageAlert9+](#routerenablebackpagealert9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | --------- | +| options | [EnableAlertOptions](#enablealertoptions) | 是 | 文本弹窗信息描述。 | + +**示例:** + + ```js + router.enableAlertBeforeBackPage({ + message: 'Message Info' + }); + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index 12c658c75628e84883cdecf837d2a290a79d4d20..51c100cadd33b3f00b64fc5dfb44d3c8f23e9643 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -148,8 +148,6 @@ - [组件内转场](ts-transition-animation-component.md) - [共享元素转场](ts-transition-animation-shared-elements.md) - [路径动画](ts-motion-path-animation.md) - - [矩阵变换](ts-matrix-transformation.md) - - [插值计算](ts-interpolation-calculation.md) - 全局UI方法 - 弹窗 - [警告弹窗](ts-methods-alert-dialog-box.md) diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-animator.md b/zh-cn/application-dev/reference/errorcodes/errorcode-animator.md new file mode 100644 index 0000000000000000000000000000000000000000..72848e1acab47797cb406ccda9ad01bc65b75099 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-animator.md @@ -0,0 +1,19 @@ +# 动画错误码 + +## 100001 内部错误 + +### 错误信息 + +Internal error. + +### 错误描述 + +当出现了开发者解决不了的内部异常错误,会报此错误码,并描述具体是哪种内部错误。 + +### 可能原因 + +未成功获取渲染引擎,解析参数失败等。 + +### 处理步骤 + +NA \ No newline at end of file diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md b/zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md new file mode 100644 index 0000000000000000000000000000000000000000..0bf40f83975af5027b176ab4df75b9739b33a8d7 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md @@ -0,0 +1,19 @@ +# 弹窗错误码 + +## 100001 内部错误 + +### 错误信息 + +Internal error. + +### 错误描述 + +当出现了开发者解决不了的内部异常错误,会报此错误码,并描述具体是哪种内部错误。 + +### 可能原因 + +未成功获取渲染引擎,解析参数失败等。 + +### 处理步骤 + +NA \ No newline at end of file diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-router.md b/zh-cn/application-dev/reference/errorcodes/errorcode-router.md new file mode 100644 index 0000000000000000000000000000000000000000..5b459aa69f62fb17f951eba7d8b747f340130057 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-router.md @@ -0,0 +1,73 @@ +# 页面路由错误码 + +## 100001 内部错误 + +### 错误信息 + +Internal error. + +### 错误描述 + +当出现了开发者解决不了的内部异常错误,系统会产生此错误码,并描述具体是哪种内部错误。 + +### 可能原因 + +未成功获取渲染引擎,解析参数失败等。 + +### 处理步骤 + +NA + +## 100002 路由输入的uri错误 + +### 错误信息 + +Uri error. The uri of router is not exist. + +### 错误描述 + +当跳转页面输入的uri错误或者不存在,系统会产生此错误码。 + +### 可能原因 + +输入的路由uri错误或者不存在。 + +### 处理步骤 + +请检查输入的路由uri是否正确。 + +## 100003 路由压入的page过多 + +### 错误信息 + +Page stack error. The pages are pushed too much. + +### 错误描述 + +当跳转页面压入页面数超过32,系统会产生此错误码。 + +### 可能原因 + +压入pages过多。 + +### 处理步骤 + +请清除多余或无效的页面。 + +## 200002 路由输入的uri错误 + +### 错误信息 + +Uri error. The uri of router is not exist. + +### 错误描述 + +当替换页面输入的uri错误或不存在,系统会产生此错误码。 + +### 可能原因 + +输入的路由uri错误或不存在。 + +### 处理步骤 + +请检查输入的路由uri是否正确。 \ No newline at end of file