跳到主要内容
版本:v8

ion-app

ion-app 是 Ionic 应用的容器元素。每个项目应该只有一个 <ion-app> 元素。一个应用可以包含许多 Ionic 组件,包括菜单、页眉、内容和页脚。当叠加层组件显示时,它们会被附加到 <ion-app> 中。

使用 ion-app 可以启用以下行为:

  • 无需任何原生插件即可使用 键盘生命周期事件
  • 在 Android 设备上自定义硬件返回键行为的 硬件返回键监听器
  • Capacitor 或 Cordova 中的状态栏支持,允许用户通过点击状态栏滚动到视图顶部
  • 滚动辅助工具,可滚动内容,使聚焦的文本输入不被屏幕键盘遮挡
  • 在 Material Design 模式下激活按钮时的 涟漪效果
  • 其他点击和聚焦工具,使 Ionic 应用的使用体验更接近原生

编程式聚焦

Ionic 为带有 ion-focusable 类的组件提供了聚焦工具。当按下某些键盘键(如 Tab )时,这些工具会自动管理组件的聚焦。组件也可以通过使用 ion-app 中的 setFocus 方法,在响应用户操作时以编程方式聚焦。

属性

No properties available for this component.

事件

No events available for this component.

方法

setFocus

DescriptionUsed to set focus on an element that uses ion-focusable. Do not use this if focusing the element as a result of a keyboard event as the focus utility should handle this for us. This method should be used when we want to programmatically focus an element as a result of another user action. (Ex: We focus the first element inside of a popover when the user presents it, but the popover is not always presented as a result of keyboard action.)
SignaturesetFocus(elements: HTMLElement[]) => Promise<void>
Parameterselements: An array of HTML elements to set focus on.

CSS Shadow Parts

No CSS shadow parts available for this component.

CSS 自定义属性

No CSS custom properties available for this component.

插槽

No slots available for this component.