fix: left and right arrows of MonthPicker cannot be worked #1543

pull/1554/head
tangjinzhou 2019-12-11 21:02:31 +08:00
parent 9dcc648378
commit c14d7357b8
2 changed files with 12 additions and 9 deletions

View File

@ -70,6 +70,14 @@ const CalendarHeader = {
this.__emit('valueChange', value);
},
changeYear(direction) {
if (direction > 0) {
this.nextYear();
} else {
this.previousYear();
}
},
monthYearElement(showTimePicker) {
const props = this.$props;
const prefixCls = props.prefixCls;
@ -158,6 +166,7 @@ const CalendarHeader = {
cellRender={props.monthCellRender}
contentRender={props.monthCellContentRender}
renderFooter={renderFooter}
changeYear={this.changeYear}
/>
);
}

View File

@ -4,9 +4,7 @@ import { hasProp } from '../../../_util/props-util';
import MonthTable from './MonthTable';
function goYear(direction) {
const next = this.sValue.clone();
next.add(direction, 'year');
this.setAndChangeValue(next);
this.changeYear(direction);
}
function noop() {}
@ -25,6 +23,7 @@ const MonthPanel = {
disabledDate: PropTypes.func,
// onSelect: PropTypes.func,
renderFooter: PropTypes.func,
changeYear: PropTypes.func.def(noop),
},
data() {
@ -44,18 +43,13 @@ const MonthPanel = {
},
},
methods: {
setAndChangeValue(value) {
this.setValue(value);
this.__emit('change', value);
},
setAndSelectValue(value) {
this.setValue(value);
this.__emit('select', value);
},
setValue(value) {
if (!hasProp(this, 'value')) {
if (hasProp(this, 'value')) {
this.setState({
sValue: value,
});