ant-design-vue/components/date-picker/demo/presetted-ranges.md

48 lines
985 B
Markdown
Raw Normal View History

2018-03-15 13:40:34 +00:00
2018-03-19 15:05:49 +00:00
<cn>
#### 预设范围
2018-03-15 13:40:34 +00:00
RangePicker 可以设置常用的 预设范围 提高用户体验。
2018-03-19 15:05:49 +00:00
</cn>
2018-03-15 13:40:34 +00:00
2018-03-19 15:05:49 +00:00
<us>
#### Presetted Ranges
2018-03-15 13:40:34 +00:00
We can set presetted ranges to RangePicker to improve user experience.
2018-03-19 15:05:49 +00:00
</us>
2018-03-15 13:40:34 +00:00
2018-03-19 15:05:49 +00:00
```html
<template>
2018-03-15 13:40:34 +00:00
<div>
2018-03-19 15:05:49 +00:00
<a-range-picker
:ranges="{ Today: [moment(), moment()], 'This Month': [moment(), moment().endOf('month')] }"
@change="onChange"
2018-03-15 13:40:34 +00:00
/>
<br />
2018-03-19 15:05:49 +00:00
<a-range-picker
:ranges="{ Today: [moment(), moment()], 'This Month': [moment(), moment().endOf('month')] }"
2018-03-15 13:40:34 +00:00
showTime
format="YYYY/MM/DD HH:mm:ss"
2018-03-19 15:05:49 +00:00
@change="onChange"
2018-03-15 13:40:34 +00:00
/>
2018-03-19 15:05:49 +00:00
</div>
</template>
<script>
import moment from 'moment';
export default {
data(){
return {
dateFormat: 'YYYY/MM/DD',
monthFormat: 'YYYY/MM',
}
},
methods: {
moment,
onChange(dates, dateStrings) {
console.log('From: ', dates[0], ', to: ', dates[1]);
console.log('From: ', dateStrings[0], ', to: ', dateStrings[1]);
},
}
}
</script>
```