2021-09-17 00:18:50 +08:00
|
|
|
<template>
|
2022-11-26 13:52:35 +08:00
|
|
|
<el-radio-group v-model="size" label="size control" size="small">
|
|
|
|
<el-radio-button label="large">large</el-radio-button>
|
|
|
|
<el-radio-button label="default">default</el-radio-button>
|
|
|
|
<el-radio-button label="small">small</el-radio-button>
|
|
|
|
</el-radio-group>
|
2021-09-17 00:18:50 +08:00
|
|
|
<div class="demo-date-picker">
|
|
|
|
<div class="block">
|
|
|
|
<span class="demonstration">Default</span>
|
2022-05-25 21:42:21 +08:00
|
|
|
<el-date-picker
|
|
|
|
v-model="value1"
|
|
|
|
type="date"
|
|
|
|
placeholder="Pick a day"
|
|
|
|
:size="size"
|
|
|
|
/>
|
2021-09-17 00:18:50 +08:00
|
|
|
</div>
|
|
|
|
<div class="block">
|
|
|
|
<span class="demonstration">Picker with quick options</span>
|
|
|
|
<el-date-picker
|
|
|
|
v-model="value2"
|
|
|
|
type="date"
|
|
|
|
placeholder="Pick a day"
|
|
|
|
:disabled-date="disabledDate"
|
|
|
|
:shortcuts="shortcuts"
|
2022-05-25 21:42:21 +08:00
|
|
|
:size="size"
|
2022-03-14 04:16:11 +08:00
|
|
|
/>
|
2021-09-17 00:18:50 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-12-21 15:51:33 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { ref } from 'vue'
|
2021-09-17 00:18:50 +08:00
|
|
|
|
2022-11-26 13:52:35 +08:00
|
|
|
const size = ref<'default' | 'large' | 'small'>('default')
|
2022-05-25 21:42:21 +08:00
|
|
|
|
2021-12-21 15:51:33 +08:00
|
|
|
const value1 = ref('')
|
|
|
|
const value2 = ref('')
|
2021-09-17 00:18:50 +08:00
|
|
|
|
2021-12-21 15:51:33 +08:00
|
|
|
const shortcuts = [
|
|
|
|
{
|
|
|
|
text: 'Today',
|
|
|
|
value: new Date(),
|
2021-09-17 00:18:50 +08:00
|
|
|
},
|
2021-12-21 15:51:33 +08:00
|
|
|
{
|
|
|
|
text: 'Yesterday',
|
|
|
|
value: () => {
|
|
|
|
const date = new Date()
|
|
|
|
date.setTime(date.getTime() - 3600 * 1000 * 24)
|
|
|
|
return date
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: 'A week ago',
|
|
|
|
value: () => {
|
|
|
|
const date = new Date()
|
|
|
|
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
|
|
|
|
return date
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
const disabledDate = (time: Date) => {
|
|
|
|
return time.getTime() > Date.now()
|
|
|
|
}
|
2021-09-17 00:18:50 +08:00
|
|
|
</script>
|
2022-11-26 13:52:35 +08:00
|
|
|
|
2022-01-31 23:43:56 +08:00
|
|
|
<style scoped>
|
|
|
|
.demo-date-picker {
|
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
padding: 0;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
}
|
2022-11-26 13:52:35 +08:00
|
|
|
|
2022-01-31 23:43:56 +08:00
|
|
|
.demo-date-picker .block {
|
|
|
|
padding: 30px 0;
|
|
|
|
text-align: center;
|
2022-03-14 19:41:41 +08:00
|
|
|
border-right: solid 1px var(--el-border-color);
|
2022-01-31 23:43:56 +08:00
|
|
|
flex: 1;
|
|
|
|
}
|
2022-11-26 13:52:35 +08:00
|
|
|
|
2022-01-31 23:43:56 +08:00
|
|
|
.demo-date-picker .block:last-child {
|
|
|
|
border-right: none;
|
|
|
|
}
|
2022-11-26 13:52:35 +08:00
|
|
|
|
2022-01-31 23:43:56 +08:00
|
|
|
.demo-date-picker .demonstration {
|
|
|
|
display: block;
|
|
|
|
color: var(--el-text-color-secondary);
|
|
|
|
font-size: 14px;
|
|
|
|
margin-bottom: 20px;
|
|
|
|
}
|
|
|
|
</style>
|