mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 09:21:22 +08:00
5a08aab0e8
* docs: DatePicker change type demo * chore: snapshot * chore * docs: DatePicker use Space * chore: snapshot
55 lines
1.2 KiB
Markdown
55 lines
1.2 KiB
Markdown
---
|
|
order: 12
|
|
title:
|
|
zh-CN: 定制日期单元格
|
|
en-US: Customized Date Rendering
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
使用 `dateRender` 可以自定义日期单元格的内容和样式。
|
|
|
|
## en-US
|
|
|
|
We can customize the rendering of date cells in the calendar by providing a `dateRender` function to `DatePicker`.
|
|
|
|
```jsx
|
|
import { DatePicker, Space } from 'antd';
|
|
|
|
const { RangePicker } = DatePicker;
|
|
|
|
ReactDOM.render(
|
|
<Space direction="vertical" size={12}>
|
|
<DatePicker
|
|
dateRender={current => {
|
|
const style = {};
|
|
if (current.date() === 1) {
|
|
style.border = '1px solid #1890ff';
|
|
style.borderRadius = '50%';
|
|
}
|
|
return (
|
|
<div className="ant-picker-cell-inner" style={style}>
|
|
{current.date()}
|
|
</div>
|
|
);
|
|
}}
|
|
/>
|
|
<RangePicker
|
|
dateRender={current => {
|
|
const style = {};
|
|
if (current.date() === 1) {
|
|
style.border = '1px solid #1890ff';
|
|
style.borderRadius = '50%';
|
|
}
|
|
return (
|
|
<div className="ant-picker-cell-inner" style={style}>
|
|
{current.date()}
|
|
</div>
|
|
);
|
|
}}
|
|
/>
|
|
</Space>,
|
|
mountNode,
|
|
);
|
|
```
|