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 = {
70
70
this . __emit ( 'valueChange' , value ) ;
71
71
} ,
72
72
73
+ changeYear ( direction ) {
74
+ if ( direction > 0 ) {
75
+ this . nextYear ( ) ;
76
+ } else {
77
+ this . previousYear ( ) ;
78
+ }
79
+ } ,
80
+
73
81
monthYearElement ( showTimePicker ) {
74
82
const props = this . $props ;
75
83
const prefixCls = props . prefixCls ;
@@ -158,6 +166,7 @@ const CalendarHeader = {
158
166
cellRender = { props . monthCellRender }
159
167
contentRender = { props . monthCellContentRender }
160
168
renderFooter = { renderFooter }
169
+ changeYear = { this . changeYear }
161
170
/>
162
171
) ;
163
172
}
Original file line number Diff line number Diff line change @@ -4,9 +4,7 @@ import { hasProp } from '../../../_util/props-util';
4
4
import MonthTable from './MonthTable' ;
5
5
6
6
function goYear ( direction ) {
7
- const next = this . sValue . clone ( ) ;
8
- next . add ( direction , 'year' ) ;
9
- this . setAndChangeValue ( next ) ;
7
+ this . changeYear ( direction ) ;
10
8
}
11
9
12
10
function noop ( ) { }
@@ -25,6 +23,7 @@ const MonthPanel = {
25
23
disabledDate : PropTypes . func ,
26
24
// onSelect: PropTypes.func,
27
25
renderFooter : PropTypes . func ,
26
+ changeYear : PropTypes . func . def ( noop ) ,
28
27
} ,
29
28
30
29
data ( ) {
@@ -44,18 +43,13 @@ const MonthPanel = {
44
43
} ,
45
44
} ,
46
45
methods : {
47
- setAndChangeValue ( value ) {
48
- this . setValue ( value ) ;
49
- this . __emit ( 'change' , value ) ;
50
- } ,
51
-
52
46
setAndSelectValue ( value ) {
53
47
this . setValue ( value ) ;
54
48
this . __emit ( 'select' , value ) ;
55
49
} ,
56
50
57
51
setValue ( value ) {
58
- if ( ! hasProp ( this , 'value' ) ) {
52
+ if ( hasProp ( this , 'value' ) ) {
59
53
this . setState ( {
60
54
sValue : value ,
61
55
} ) ;
You can’t perform that action at this time.
0 commit comments