You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.0 KiB
55 lines
1.0 KiB
7 years ago
|
---
|
||
|
order: 12
|
||
|
title:
|
||
|
zh-CN: <Missing>
|
||
|
en-US: Customized Date Rendering
|
||
|
---
|
||
|
|
||
|
## zh-CN
|
||
|
|
||
|
<Missing>
|
||
|
|
||
|
## en-US
|
||
|
|
||
|
We can customize the rendering of date cells in the calendar by providing a `dateRender` function to `DatePicker`.
|
||
|
|
||
|
````jsx
|
||
|
import { DatePicker } from 'antd';
|
||
|
const { RangePicker } = DatePicker;
|
||
|
|
||
|
ReactDOM.render(
|
||
|
<div>
|
||
|
<DatePicker
|
||
|
dateRender={(current) => {
|
||
|
const style = {};
|
||
|
if (current.date() === 1) {
|
||
|
style.border = '1px solid';
|
||
|
style.borderRadius = '50%';
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<div className="ant-calendar-date" style={style}>
|
||
|
{current.date()}
|
||
|
</div>
|
||
|
);
|
||
|
}}
|
||
|
/>
|
||
|
<RangePicker
|
||
|
dateRender={(current) => {
|
||
|
const style = {};
|
||
|
if (current.date() === 1) {
|
||
|
style.border = '1px solid';
|
||
|
style.borderRadius = '50%';
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<div className="ant-calendar-date" style={style}>
|
||
|
{current.date()}
|
||
|
</div>
|
||
|
);
|
||
|
}}
|
||
|
/>
|
||
|
</div>
|
||
|
, mountNode);
|
||
|
````
|