2016-11-07 16:31:15 +08:00
|
|
|
---
|
|
|
|
order: 8
|
|
|
|
title:
|
2016-11-15 17:16:20 +08:00
|
|
|
zh-CN: 预设范围
|
|
|
|
en-US: Presetted Ranges
|
2016-11-07 16:31:15 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
2016-11-15 17:16:20 +08:00
|
|
|
RangePicker 可以设置常用的 预设范围 提高用户体验。
|
2016-11-07 16:31:15 +08:00
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2016-11-15 17:16:20 +08:00
|
|
|
We can set presetted ranges to RangePicker to improve user experience.
|
2016-11-07 16:31:15 +08:00
|
|
|
|
2017-02-13 10:55:53 +08:00
|
|
|
````jsx
|
2016-11-07 16:31:15 +08:00
|
|
|
import { DatePicker } from 'antd';
|
|
|
|
import moment from 'moment';
|
|
|
|
const RangePicker = DatePicker.RangePicker;
|
|
|
|
|
|
|
|
function onChange(dates, dateStrings) {
|
|
|
|
console.log('From: ', dates[0], ', to: ', dates[1]);
|
|
|
|
console.log('From: ', dateStrings[0], ', to: ', dateStrings[1]);
|
|
|
|
}
|
2017-05-15 16:36:07 +08:00
|
|
|
|
2016-11-07 16:31:15 +08:00
|
|
|
ReactDOM.render(
|
|
|
|
<div>
|
|
|
|
<RangePicker
|
|
|
|
ranges={{ Today: [moment(), moment()], 'This Month': [moment(), moment().endOf('month')] }}
|
2016-11-15 17:16:20 +08:00
|
|
|
onChange={onChange}
|
2016-11-07 16:31:15 +08:00
|
|
|
/>
|
|
|
|
<br />
|
|
|
|
<RangePicker
|
|
|
|
ranges={{ Today: [moment(), moment()], 'This Month': [moment(), moment().endOf('month')] }}
|
2017-05-15 14:37:22 +08:00
|
|
|
showTime
|
|
|
|
format="YYYY/MM/DD HH:mm:ss"
|
|
|
|
onChange={onChange}
|
2016-11-07 16:31:15 +08:00
|
|
|
/>
|
|
|
|
</div>,
|
|
|
|
mountNode
|
|
|
|
);
|
|
|
|
````
|