SuperAPI AI 工具集

el-datetime-picker

前端与建站

查看项目

更新于 10-15 23:32

技能介绍

用途:DateTimePicker 是 Element Plus 提供的日期时间选择组件,可在同一个选择器中同时选择日期与时间,典型场景包括时间点选择、日期时间范围选择、排期与事件创建。

主要能力:支持时间点选择(type="datetime")和日期时间范围选择(type="datetimerange"),可设置范围分隔符与起止占位文本;支持默认时间(default-time)、显示格式(format)、值格式(value-format)、面板日期格式(date-format)、面板时间格式(time-format)以及箭头控制(arrow-control)。

必要用法:基础用法为 <el-date-picker v-model="value" type="datetime" placeholder="Select date and time" />,配合 Vue 的 ref 绑定值。范围选择使用 type="datetimerange" 并传入数组绑定值。设置默认时间时使用 :default-time,例如传入两个 Date 对象分别表示起止时间。需要字符串值时设置 value-format,例如 value-format="YYYY-MM-DD HH:mm:ss"。

事件与暴露方法:提供 change、blur、focus、calendar-change、visible-change 事件,以及 focus、blur 方法。

最佳实践:使用 default-time 保证时间值一致;使用 value-format 获取字符串值;使用 arrow-control 精确选择时间。

限制:资料未提供安装命令、版本要求、浏览器兼容性、性能或收费信息。