开始使用
复制一个包含安装步骤和整个 Markdown 指南的设置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-date-picker`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/date-picker/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
安装
安装您可以使用我们的 AI 助手设置来安装插件。使用以下命令将 Capgo 技能添加到您的 AI 工具中:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下提示:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-date-picker` plugin in my project.如果您更喜欢手动设置,请运行以下命令并按照以下平台特定的说明进行操作:
npm install @capgo/capacitor-date-pickernpx cap syncimport { DatePicker } from '@capgo/capacitor-date-picker';选择日期
选择一个日期const result = await DatePicker.present({ mode: 'date', date: '2026-05-27', min: '2026-01-01', max: '2026-12-31', format: 'yyyy-MM-dd', title: 'Select date',});
console.log(result.value);选择一个时间
选择一个时间const result = await DatePicker.present({ mode: 'time', is24h: true, minuteStep: 15, format: 'HH:mm', title: 'Select time',});
console.log(result.value);选择日期和时间
选择日期和时间const result = await DatePicker.present({ mode: 'dateAndTime', date: '2026-05-27T14:30:00', format: "yyyy-MM-dd'T'HH:mm:ss", title: 'Select date and time',});选择一个月份
复制到剪贴板const result = await DatePicker.present({ mode: 'yearAndMonth', date: '2026-05-01', format: 'yyyy-MM', title: 'Select month',});复制到剪贴板
Section titled “选择范围”const range = await DatePicker.presentRange({ start: '2026-05-01', end: '2026-05-27', format: 'yyyy-MM-dd', startTitle: 'Start date', endTitle: 'End date',});
console.log(range.start, range.end, range.value);await DatePicker.hide();await DatePicker.present({ mode: 'date', date: '2026-05-27', title: 'Select date', ios: { style: 'inline', theme: 'light', }, android: { theme: 'light', },});| 选项 | 描述 |
|---|---|
mode | date, time, dateAndTime, yearAndMonth, countDownTimer或 range. |
date | 初始选中值。 |
min / max | 最小和最大可选择值。 |
format | 输出格式。支持 ISO、Java/Unicode 和常见 Moment-style 格式。 |
title | 对话标题。 |
locale | 本地选择器使用的区域设置(支持本地选择器)。 |
timezone | 用于解析和格式化的时区。 |
is24h | 偏好 24 小时时间。 |
minuteStep | 时间选择器分钟间隔。 |
doneText / cancelText | 自定义操作标签。 |
示例应用
名为“示例应用”的部分仓库包含一个 Capacitor 示例应用,用于打开原生日期选择器、时间选择器、范围选择器和插件版本调用。 hide()iOS
| Android | 动画 iOS demo:@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-date-picker 打开、选择日期并关闭 |
|---|---|
![]() | ![]() |
The complete API reference is maintained in the package README and TypeScript definitions:

