Skip to content
On this page

datePicker 组件

Element Plus 日期选择器文档

Hidden Title

基础用法:<s-date-picker v-model="dateValue"></s-date-picker>

属性事件插槽简介

基础用法

成华主题

石景山主题

日期时间

年月周和多选

范围选择

禁用状态和禁用日期

快捷选项

格式化

时间戳

默认面板日期和默认时间

高度

标题和组合属性

控制面板和插槽

选择 7 天以内的日期

属性

属性名说明类型可选值默认值
modelValue绑定值,支持 v-modelstring / number / Date / array-''
type选择器类型stringyear / years / month / months / date / dates / week / datetime / daterange / datetimerange / monthrange / yearrangedate
title左侧标题文案string-''
width组件整体宽度string / number-300px
height组件整体高度string / number-''
compTitleStyle左侧标题组件样式object-{}
theme主题样式stringdefault / chenghua / shijingshandefault
format显示在输入框中的格式string-type 自动设置
value-format绑定值的格式,支持传 x 返回毫秒时间戳,传 X 返回秒时间戳string-type 自动设置
placeholder非范围选择时的占位文案string-请选择日期
start-placeholder范围选择开始占位文案string-开始日期
end-placeholder范围选择结束占位文案string-结束日期
range-separator范围选择分隔符string--
shortcuts快捷选项,传 false 关闭内置快捷项array / false-内置快捷项
default-value面板打开时默认显示的日期Date / Date[]--
default-time范围选择时默认补全的时间Date / Date[]--
disabled-date禁用日期判断函数function(date: Date) => boolean-
size输入框尺寸,支持顶层传入和全局默认配置stringlarge / default / small''
clearable是否显示清除按钮booleantrue / falsetrue
readonly是否只读booleantrue / falsefalse
disabled是否禁用booleantrue / falsefalse
editable文本框是否可输入booleantrue / falsetrue
unlink-panels范围选择时是否取消两个日期面板之间的联动booleantrue / falsefalse
show-week-number是否显示周数booleantrue / falsefalse
prefix-icon自定义前缀图标string / Component-''
clear-icon自定义清除图标string / Component--
popper-class下拉面板类名string--
popper-style下拉面板样式string / object / array--

事件

事件名说明回调参数
update:modelValue绑定值变化时触发value
change用户确认选中值时触发value
focus输入框聚焦时触发event
blur输入框失焦时触发event
calendar-change范围选择时,日历选中项变化触发value
visible-change下拉面板显示或隐藏时触发visible

方法

方法名说明参数
focus聚焦输入框-
blur使输入框失焦-
handleOpen打开日期选择面板-
handleClose关闭日期选择面板-

插槽

插槽名说明参数
default自定义日期单元格内容cell
range-separator自定义范围选择分隔内容-

默认行为

  • 默认透传给 el-date-pickertype="date"value-format="YYYY-MM-DD"format="YYYY-MM-DD"
  • type 可选值:yearyearsmonthmonthsdatedatesweekdatetimedaterangedatetimerangemonthrangeyearrange
  • datetime / datetimerange 默认 formatvalue-formatYYYY-MM-DD HH:mm:ss
  • year / years / yearrange 默认 formatvalue-formatYYYY
  • month / months / monthrange 默认 formatvalue-formatYYYY-MM
  • 范围快捷项会按自然日边界计算,日期时间范围开始为 00:00:00.000,结束为 23:59:59.999
  • 非范围选择内置快捷项:今天、昨天、7天前、30天前。
  • daterange / datetimerange 内置快捷项:今天、昨天、最近7天、最近30天、最近90天、最近1年、本周至今、本月至今、本季度至今、今年至今、上周、上月、上季度、去年。
  • monthrange 内置快捷项:本月、上月、最近3个月、最近6个月、最近12个月、今年至今、去年。
  • yearrange 内置快捷项:今年、去年、最近3年、最近5年、最近10年。
  • 组件继承 el-date-picker 的属性、事件、插槽,并额外支持 titlewidthheighttheme

思云博智私有前端组件库