File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
components/vc-calendar/src Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,14 @@ const CalendarHeader = {
7070 this . __emit ( 'valueChange' , value ) ;
7171 } ,
7272
73+ changeYear ( direction ) {
74+ if ( direction > 0 ) {
75+ this . nextYear ( ) ;
76+ } else {
77+ this . previousYear ( ) ;
78+ }
79+ } ,
80+
7381 monthYearElement ( showTimePicker ) {
7482 const props = this . $props ;
7583 const prefixCls = props . prefixCls ;
@@ -158,6 +166,7 @@ const CalendarHeader = {
158166 cellRender = { props . monthCellRender }
159167 contentRender = { props . monthCellContentRender }
160168 renderFooter = { renderFooter }
169+ changeYear = { this . changeYear }
161170 />
162171 ) ;
163172 }
Original file line number Diff line number Diff line change @@ -4,9 +4,7 @@ import { hasProp } from '../../../_util/props-util';
44import MonthTable from './MonthTable' ;
55
66function goYear ( direction ) {
7- const next = this . sValue . clone ( ) ;
8- next . add ( direction , 'year' ) ;
9- this . setAndChangeValue ( next ) ;
7+ this . changeYear ( direction ) ;
108}
119
1210function noop ( ) { }
@@ -25,6 +23,7 @@ const MonthPanel = {
2523 disabledDate : PropTypes . func ,
2624 // onSelect: PropTypes.func,
2725 renderFooter : PropTypes . func ,
26+ changeYear : PropTypes . func . def ( noop ) ,
2827 } ,
2928
3029 data ( ) {
@@ -44,18 +43,13 @@ const MonthPanel = {
4443 } ,
4544 } ,
4645 methods : {
47- setAndChangeValue ( value ) {
48- this . setValue ( value ) ;
49- this . __emit ( 'change' , value ) ;
50- } ,
51-
5246 setAndSelectValue ( value ) {
5347 this . setValue ( value ) ;
5448 this . __emit ( 'select' , value ) ;
5549 } ,
5650
5751 setValue ( value ) {
58- if ( ! hasProp ( this , 'value' ) ) {
52+ if ( hasProp ( this , 'value' ) ) {
5953 this . setState ( {
6054 sValue : value ,
6155 } ) ;
You can’t perform that action at this time.
0 commit comments