Date Picker
March 21, 2023
Use `format` to control displayed text's `format` in the input box. Use `value-format` to control binding value's format.
By default, the component accepts and emits a Date
object.
Check the list here of all available formats of Day.js.
Note
Pay attention to capitalization
Emits Date object
Value:
Use value-format
Value๏ผ
Timestamp
Value๏ผ
Viwer Source
<template>
<div class="demo-date-picker">
<div class="block">
<span class="demonstration">Emits Date object</span>
<div class="demonstration">Value: {{ value1 }}</div>
<field-date-picker
v-model="value1"
type="date"
placeholder="Pick a Date"
format="YYYY/MM/DD"
/>
</div>
<div class="block">
<span class="demonstration">Use value-format</span>
<div class="demonstration">Value๏ผ{{ value2 }}</div>
<field-date-picker
v-model="value2"
type="date"
placeholder="Pick a Date"
format="YYYY/MM/DD"
value-format="YYYY-MM-DD"
/>
</div>
<div class="block">
<span class="demonstration">Timestamp</span>
<div class="demonstration">Value๏ผ{{ value3 }}</div>
<field-date-picker
v-model="value3"
type="date"
placeholder="Pick a Date"
format="YYYY/MM/DD"
value-format="x"
/>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
const value1 = ref('')
const value2 = ref('')
const value3 = ref('')
</script>
<style scoped>
.demo-date-picker {
display: flex;
width: 100%;
padding: 0;
flex-wrap: wrap;
}
.demo-date-picker .block {
padding: 30px 0;
text-align: center;
border-right: solid 1px var(--el-border-color);
flex: 1;
}
.demo-date-picker .block:last-child {
border-right: none;
}
.demo-date-picker .demonstration {
display: block;
color: var(--el-text-color-secondary);
font-size: 14px;
margin-bottom: 20px;
}
</style>
Props
Name | Description | Type | Mandatory |
---|---|---|---|
type | type of the picker | string | True |
Attributes
Name | Description | Type | Default |
---|---|---|---|
value | binding value, if it is an array, the length should be 2 | Date / number / string / Array | โโโโโโ |
format | format of the displayed value in the input box | string | YYYY-MM-DD |
shortcuts | an object array to set shortcut options | Array | โโโโโโ |
placeholder | placeholder in non-range mode | string | โโโโโโ |
startPlaceholder | placeholder in non-range mode | string | โโโโโโ |
endPlaceholder | placeholder in non-range mode | string | โโโโโโ |
disabled | whether Switch is disabled | boolean | False |
clearable | whether to show clear button | boolean | False |
size | size of Switch large / default / small | string | default |
Slots
Name | Description |
---|---|
header | Customize Default Content Top |
footer | Customize Default Content Bottom |
Example for Developer
Directory
โโ src # Main source code.
โโโ Components # Global components
โโโ Atoms # Atom components
โโโ FieldDatePicker # Field DatePicker specific components.