2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 1
|
2016-09-09 13:55:21 +08:00
|
|
|
title:
|
2016-05-22 11:03:07 +08:00
|
|
|
zh-CN: 自定义渲染
|
|
|
|
en-US: Custom Render
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-11-13 19:19:08 +08:00
|
|
|
|
2016-05-22 11:03:07 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2015-11-13 19:19:08 +08:00
|
|
|
用 `dateCellRender` 和 `monthCellRender` 函数来自定义需要渲染的数据。
|
|
|
|
|
2016-05-22 11:03:07 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
This component can be rendered by using `dateCellRender` and `monthCellRender` with the data you need.
|
|
|
|
|
2015-11-13 19:19:08 +08:00
|
|
|
````jsx
|
|
|
|
import { Calendar } from 'antd';
|
2016-09-09 13:55:21 +08:00
|
|
|
import moment from 'moment';
|
2015-11-13 19:19:08 +08:00
|
|
|
|
2015-12-28 11:28:00 +08:00
|
|
|
function dateCellRender(value) {
|
2016-10-02 08:55:40 +08:00
|
|
|
return <div>Custom date {value.date()}</div>;
|
2015-11-13 19:19:08 +08:00
|
|
|
}
|
|
|
|
|
2015-12-28 11:28:00 +08:00
|
|
|
function monthCellRender(value) {
|
2016-10-02 08:55:40 +08:00
|
|
|
return <div>Custom monthly {value.month()}</div>;
|
2015-11-13 19:19:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(
|
2016-09-09 13:55:21 +08:00
|
|
|
<Calendar defaultValue={moment('2010-10-10', 'YYYY-MM-DD')}
|
2016-06-06 13:54:10 +08:00
|
|
|
dateCellRender={dateCellRender} monthCellRender={monthCellRender}
|
|
|
|
/>
|
2015-12-29 12:08:58 +08:00
|
|
|
, mountNode);
|
2015-11-13 19:19:08 +08:00
|
|
|
````
|