2018-09-14 22:50:35 +08:00
|
|
|
---
|
2019-12-11 23:32:19 +08:00
|
|
|
order: 99
|
2018-09-14 22:50:35 +08:00
|
|
|
debug: true
|
|
|
|
title:
|
|
|
|
zh-CN: 后缀图标
|
|
|
|
en-US: Suffix
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
最简单的用法,在浮层中可以选择或者输入日期。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Basic use case. Users can select or input a date in panel.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2019-11-28 12:34:33 +08:00
|
|
|
import { SmileOutlined } from '@ant-design/icons';
|
2022-05-21 22:14:15 +08:00
|
|
|
import { DatePicker, Space } from 'antd';
|
2022-05-21 23:04:51 +08:00
|
|
|
import type { Dayjs } from 'dayjs';
|
2022-05-21 22:14:15 +08:00
|
|
|
import React from 'react';
|
2018-09-14 22:50:35 +08:00
|
|
|
|
2019-11-28 12:34:33 +08:00
|
|
|
const smileIcon = <SmileOutlined />;
|
2019-12-11 23:32:19 +08:00
|
|
|
const { RangePicker } = DatePicker;
|
2018-09-14 22:50:35 +08:00
|
|
|
|
2022-05-21 23:04:51 +08:00
|
|
|
type DatePickerValue = Dayjs | null;
|
|
|
|
type RangePickerValue = [Dayjs | null, Dayjs | null] | null;
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
const onChange = (
|
|
|
|
date: DatePickerValue | RangePickerValue,
|
|
|
|
dateString: [string, string] | string,
|
|
|
|
) => {
|
2018-09-14 22:50:35 +08:00
|
|
|
console.log(date, dateString);
|
2022-05-19 09:46:26 +08:00
|
|
|
};
|
2018-09-14 22:50:35 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => (
|
2020-07-30 19:17:34 +08:00
|
|
|
<Space direction="vertical" size={12}>
|
2018-09-16 19:39:43 +08:00
|
|
|
<DatePicker suffixIcon={smileIcon} onChange={onChange} />
|
2019-12-11 23:32:19 +08:00
|
|
|
<DatePicker suffixIcon={smileIcon} onChange={onChange} picker="month" />
|
2018-09-16 19:39:43 +08:00
|
|
|
<RangePicker suffixIcon={smileIcon} onChange={onChange} />
|
2019-12-11 23:32:19 +08:00
|
|
|
<DatePicker suffixIcon={smileIcon} onChange={onChange} picker="week" />
|
2018-09-16 19:39:43 +08:00
|
|
|
<DatePicker suffixIcon="ab" onChange={onChange} />
|
2019-12-11 23:32:19 +08:00
|
|
|
<DatePicker suffixIcon="ab" onChange={onChange} picker="month" />
|
2018-09-16 19:39:43 +08:00
|
|
|
<RangePicker suffixIcon="ab" onChange={onChange} />
|
2019-12-11 23:32:19 +08:00
|
|
|
<DatePicker suffixIcon="ab" onChange={onChange} picker="week" />
|
2022-04-03 23:27:45 +08:00
|
|
|
</Space>
|
2018-11-28 15:00:03 +08:00
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|