跳到主要内容
版本:v8

ion-app

App 是 Ionic 应用的容器元素。每个项目只应有一个 <ion-app> 元素。一个应用可以包含许多 Ionic 组件,包括菜单、头部、内容和底部。覆盖层组件在显示时会被附加到 <ion-app> 中。

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

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

编程式焦点

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

Properties

该组件没有可用的属性。

Events

该组件没有可用的事件。

Methods

setFocus

说明Used 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.)
签名setFocus(elements: HTMLElement[]) => Promise<void>
参数elements: An array of HTML elements to set focus on.

CSS Shadow Parts

该组件没有可用的 CSS 阴影部分。

CSS Custom Properties

该组件没有可用的 CSS 自定义属性。

Slots

该组件没有可用的插槽。