Date Picker
# FxDatePicker Date Picker
Different interaction patterns exist between mobile and PC, hence more parameter variations. For mobile usage, please refer directly to the mobile section at the bottom.
For selecting or inputting dates.
# Date Selection
Basic date picker with "day" as the fundamental unit.
# Other Date Units
Extended date selection allows choosing weeks, months, years, or multiple dates.
# Date Range Selection
Conveniently select a time range within one picker.
# Month Range Selection
Conveniently select a month range within one picker.
# Date Format
Use format to specify the display format in the input box; use value-format to specify the binding value format.
By default, the component accepts and returns Date objects. Below are available format strings (UTC example: January 2, 2017 03:04:05):
:::warning Note letter casing :::
| Format | Meaning | Notes | Example |
|---|---|---|---|
yyyy | Year | 2017 | |
M | Month | No padding | 1 |
MM | Month | 01 | |
W | Week | Only for week picker format; no padding | 1 |
WW | Week | Only for week picker format | 01 |
d | Day | No padding | 2 |
dd | Day | 02 | |
H | Hour | 24-hour; no padding | 3 |
HH | Hour | 24-hour | 03 |
h | Hour | 12-hour, must use with A/a; no padding | 3 |
hh | Hour | 12-hour, must use with A/a | 03 |
m | Minute | No padding | 4 |
mm | Minute | 04 | |
s | Second | No padding | 5 |
ss | Second | 05 | |
A | AM/PM | Only for format, uppercase | AM |
a | am/pm | Only for format, lowercase | am |
timestamp | JS timestamp | Only for value-format; bound value is number type | 1483326245000 |
# Default Display Date
Specify default time for start/end dates in range selection.
Component value:
# Attributes
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| value / v-model | Binding value | date(DatePicker) / array(DateRangePicker) | — | — |
| readonly | Read-only | boolean | — | false |
| disabled | Disabled | boolean | — | false |
| editable | Text input enabled | boolean | — | true |
| clearable | Show clear button | boolean | — | true |
| size | Input size | string | large, small, mini | — |
| placeholder | Placeholder for non-range | string | — | — |
| start-placeholder | Start date placeholder | string | — | — |
| end-placeholder | End date placeholder | string | — | — |
| type | Display type | string | year/month/date/dates/week/datetime/datetimerange/daterange/monthrange | date |
| format | Display format | string | See Date Format | yyyy-MM-dd |
| align | Alignment | string | left, center, right | left |
| popper-class | Dropdown class name | string | — | — |
| picker-options | Picker options (see below) | object | — | {} |
| range-separator | Range separator | string | — | '-' |
| default-value | Default display date | Date | Parsable by new Date() | — |
| default-time | Default time for ranges | string[] | Array of two time strings (e.g. ['00:00:00', '23:59:59']) | — |
| value-format | Binding value format | string | See Date Format | — |
| name | Native attribute | string | — | — |
| unlink-panels | Unlink range panels | boolean | — | false |
| prefix-icon | Custom prefix icon class | string | — | el-icon-date |
| clear-icon | Custom clear icon class | string | — | el-icon-circle-close |
| validate-event | Trigger validation | boolean | — | true |
# Picker Options
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| shortcuts | Quick options ({ text, onClick } objects) | Object[] | — | — |
| disabledDate | Disable dates (returns Boolean) | Function | — | — |
| firstDayOfWeek | First day of week | Number | 1-7 | 7 |
| onPick | Callback after selection (daterange/datetimerange only) | Function({ maxDate, minDate }) | — | — |
# Shortcuts
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| text | Display text | string | — | — |
| backfillShortcutActive | Set as default active shortcut | boolean | — | — |
| backfillShortcut | Backfill shortcut text | boolean | — | — |
| onClick | Callback (emits 'pickByShortcut' event) | function | — | — |
# Events
| Event | Description | Parameters |
|---|---|---|
| change | On confirmation | Component binding value |
| blur | On input blur | Component instance |
| focus | On input focus | Component instance |
# Methods
| Method | Description | Parameters |
|---|---|---|
| focus | Focus input | — |
| setShortcutHighlight | Highlight shortcut | Shortcut text |
# Mobile Date Picker
Supports date (year-month-day) selection.
# Usage Guide
# Basic Usage
With .sync modifier on visible, the component manages popup visibility automatically.
<template>
<fx-date-picker
:visible.sync