mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
997 B
997 B
order | title | ||||
---|---|---|---|---|---|
8 |
|
zh-CN
可以预设常用的日期范围以提高用户体验。
en-US
We can set preset ranges to RangePicker to improve user experience.
import { DatePicker, Space } from 'antd';
import dayjs from 'dayjs';
const { RangePicker } = DatePicker;
function onChange(dates, dateStrings) {
console.log('From: ', dates[0], ', to: ', dates[1]);
console.log('From: ', dateStrings[0], ', to: ', dateStrings[1]);
}
export default () => (
<Space direction="vertical" size={12}>
<RangePicker
ranges={{
Today: [dayjs(), dayjs()],
'This Month': [dayjs().startOf('month'), dayjs().endOf('month')],
}}
onChange={onChange}
/>
<RangePicker
ranges={{
Today: [dayjs(), dayjs()],
'This Month': [dayjs().startOf('month'), dayjs().endOf('month')],
}}
showTime
format="YYYY/MM/DD HH:mm:ss"
onChange={onChange}
/>
</Space>
);