Skip to main content

ion-datetime-button

shadow

日期时间按钮与 日期时间 组件链接以显示格式化的日期和时间。它还提供了在模式、弹出窗口等中显示日期时间的按钮。

¥Datetime Button links with a Datetime component to display the formatted date and time. It also provides buttons to present the datetime in a modal, popover, and more.

概述

¥Overview

当空间有限时应使用日期时间按钮。该组件显示显示当前日期和时间值的按钮。点击按钮后,日期或时间选择器将在叠加层中打开。

¥Datetime Button should be used when space is constrained. This component displays buttons which show the current date and time values. When the buttons are tapped, the date or time pickers open in the overlay.

将日期时间按钮与 JavaScript 框架(例如 Angular、React 或 Vue)一起使用时,请务必使用 ion-modal 上的 keepContentsMounted 属性ion-popover 上的 keepContentsMounted 属性。这允许安装链接的日期时间实例,即使覆盖尚未渲染。

¥When using Datetime Button with a JavaScript framework such as Angular, React, or Vue be sure to use the keepContentsMounted property on ion-modal or the keepContentsMounted property on ion-popover. This allows the linked datetime instance to be mounted even if the overlay has not been presented yet.

基本用法

¥Basic Usage

本土化

¥Localization

ion-datetime-button 上的本地化文本由关联的 ion-datetime 实例上的 locale 属性确定。详细信息请参见 日期时间本地化

¥The localized text on ion-datetime-button is determined by the locale property on the associated ion-datetime instance. See Datetime Localization for more details.

格式选项

¥Format Options

你可以通过在关联的日期时间实例上提供 formatOptions 来自定义日期时间按钮中的日期和时间的格式。详细信息请参见 日期时间格式选项

¥You can customize the format of the date and time in a Datetime Button by providing formatOptions on the associated Datetime instance. See Datetime Format Options for more details.

与模态框和弹出框一起使用

¥Usage with Modals and Popovers

ion-datetime-button 必须与已安装的 ion-datetime 实例关联。因此,必须使用 内嵌模态框内联弹出窗口(且 keepContentsMounted 属性设置为 true)。

¥ion-datetime-button must be associated with a mounted ion-datetime instance. As a result, Inline Modals and Inline Popovers with the keepContentsMounted property set to true must be used.

属性

¥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
Default'primary'

datetime

DescriptionThe ID of the ion-datetime instance associated with the datetime button.
Attributedatetime
Typestring | undefined
Defaultundefined

disabled

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

mode

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

事件

¥Events

No events available for this component.

方法

¥Methods

No public methods available for this component.

CSS 阴影部分

¥CSS Shadow Parts

NameDescription
nativeThe native HTML button that wraps the slotted text.

CSS 自定义属性

¥CSS Custom Properties

No CSS custom properties available for this component.

插槽

¥Slots

NameDescription
date-targetContent displayed inside of the date button.
time-targetContent displayed inside of the time button.