Skip to main content

ion-back-button

shadow

单击后退按钮可在应用的历史记录中导航回来。仅当导航堆栈中有历史记录时才显示,除非设置了 defaultHref。后退按钮根据模式显示不同的文本和图标,但这可以自定义。

¥The back button navigates back in the app's history when clicked. It is only displayed when there is history in the navigation stack, unless defaultHref is set. The back button displays different text and icon based on the mode, but this can be customized.

基本用法

¥Basic Usage

自定义后退按钮

¥Custom Back Button

默认情况下,后退按钮将显示文本 "Back",在 ios 上显示 "chevron-back" 图标,在 md 上显示 "arrow-back-sharp" 图标。可以通过设置 icontext 属性来自定义每个后退按钮组件。或者,可以使用全局配置中的 backButtonIconbackButtonText 属性进行全局设置。请参阅 配置文档 了解更多信息。

¥By default, the back button will display the text "Back" with a "chevron-back" icon on ios, and an "arrow-back-sharp" icon on md. This can be customized per back button component by setting the icon or text properties. Alternatively, it can be set globally using the backButtonIcon or backButtonText properties in the global config. See the Config docs for more information.

默认返回历史记录

¥Default Back History

有时,应用可能需要显示后退按钮并在没有历史记录时导航回来。这可以通过将后退按钮上的 defaultHref 设置为路径来完成。为了使用 defaultHref,应用必须包含已设置路径的路由。

¥Occasionally an app may need to show the back button and navigate back when there is no history. This can be done by setting the defaultHref on the back button to a path. In order to use defaultHref, the app must contain a router with paths set.

属性

¥Properties

color

DescriptionThe color to use from your application's color palette. Default options are: "primary", "secondary", "tertiary", "success", "warning", "danger", "light", "medium", and "dark". For more information on colors, see theming.
Attributecolor
Type"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string | undefined
Defaultundefined

defaultHref

DescriptionThe url to navigate back to by default when there is no history.
Attributedefault-href
Typestring | undefined
Defaultundefined

disabled

DescriptionIf true, the user cannot interact with the button.
Attributedisabled
Typeboolean
Defaultfalse

icon

DescriptionThe built-in named SVG icon name or the exact src of an SVG file to use for the back button.
Attributeicon
Typenull | string | undefined
Defaultundefined

mode

DescriptionThe mode determines which platform styles to use.
Attributemode
Type"ios" | "md"
Defaultundefined

routerAnimation

DescriptionWhen using a router, it specifies the transition animation when navigating to another page.
Attributeundefined
Type((baseEl: any, opts?: any) => Animation) | undefined
Defaultundefined

text

DescriptionThe text to display in the back button.
Attributetext
Typenull | string | undefined
Defaultundefined

type

DescriptionThe type of the button.
Attributetype
Type"button" | "reset" | "submit"
Default'button'

事件

¥Events

No events available for this component.

方法

¥Methods

No public methods available for this component.

CSS 阴影部分

¥CSS Shadow Parts

NameDescription
iconThe back button icon (uses ion-icon).
nativeThe native HTML button element that wraps all child elements.
textThe back button text.

CSS 自定义属性

¥CSS Custom Properties

NameDescription
--backgroundBackground of the button
--background-focusedBackground of the button when focused with the tab key
--background-focused-opacityOpacity of the button background when focused with the tab key
--background-hoverBackground of the button on hover
--background-hover-opacityOpacity of the background on hover
--border-radiusBorder radius of the button
--colorText color of the button
--color-focusedText color of the button when focused with the tab key
--color-hoverText color of the button on hover
--icon-font-sizeFont size of the button icon
--icon-font-weightFont weight of the button icon
--icon-margin-bottomBottom margin of the button icon
--icon-margin-endRight margin if direction is left-to-right, and left margin if direction is right-to-left of the button icon
--icon-margin-startLeft margin if direction is left-to-right, and right margin if direction is right-to-left of the button icon
--icon-margin-topTop margin of the button icon
--icon-padding-bottomBottom padding of the button icon
--icon-padding-endRight padding if direction is left-to-right, and left padding if direction is right-to-left of the button icon
--icon-padding-startLeft padding if direction is left-to-right, and right padding if direction is right-to-left of the button icon
--icon-padding-topTop padding of the button icon
--margin-bottomBottom margin of the button
--margin-endRight margin if direction is left-to-right, and left margin if direction is right-to-left of the button
--margin-startLeft margin if direction is left-to-right, and right margin if direction is right-to-left of the button
--margin-topTop margin of the button
--min-heightMinimum height of the button
--min-widthMinimum width of the button
--opacityOpacity of the button
--padding-bottomBottom padding of the button
--padding-endRight padding if direction is left-to-right, and left padding if direction is right-to-left of the button
--padding-startLeft padding if direction is left-to-right, and right padding if direction is right-to-left of the button
--padding-topTop padding of the button
--ripple-colorColor of the button ripple effect
--transitionTransition of the button

插槽

¥Slots

No slots available for this component.