mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 03:29:59 +08:00
add onTypeChange
This commit is contained in:
parent
522c3fb0e7
commit
62bc47300a
@ -39,9 +39,11 @@ function getDateData(value) {
|
||||
function onChange(value) {
|
||||
console.log('change');
|
||||
}
|
||||
|
||||
function onTypeChange(type) {
|
||||
console.log('Type change: %s.', type);
|
||||
}
|
||||
|
||||
ReactDOM.render(
|
||||
<div style={{ width: 290, border: '1px solid #d9d9d9', borderRadius: 4 }}><Calendar getDateData={getDateData} onChange={onChange} type="date" /></div>
|
||||
<div style={{ width: 290, border: '1px solid #d9d9d9', borderRadius: 4 }}><Calendar getDateData={getDateData} onChange={onChange} onTypeChange={onTypeChange} type="date" /></div>
|
||||
, document.getElementById('components-calendar-demo-basic'));
|
||||
````
|
||||
|
@ -80,7 +80,9 @@ class NoticeCalendar extends Component {
|
||||
}
|
||||
}
|
||||
setType(type) {
|
||||
const oldType = this.state.type;
|
||||
this.setState({ type });
|
||||
this.props.onTypeChange(type, oldType);
|
||||
}
|
||||
onPanelChange(value) {
|
||||
if (this.state.type === 'month') {
|
||||
@ -131,6 +133,7 @@ NoticeCalendar.propTypes = {
|
||||
className: PropTypes.string,
|
||||
style: PropTypes.object,
|
||||
onChange: PropTypes.func,
|
||||
onTypeChange: PropTypes.func,
|
||||
};
|
||||
NoticeCalendar.defaultProps = {
|
||||
locale: CalendarLocale,
|
||||
@ -139,6 +142,7 @@ NoticeCalendar.defaultProps = {
|
||||
fullscreen: false,
|
||||
prefixCls: PREFIX_CLS,
|
||||
onChange: noop,
|
||||
onTypeChange: noop,
|
||||
type: 'date',
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user