@@ -70,44 +70,46 @@ export default {
70
70
const activeKey = this . stateActiveKey ;
71
71
const { prefixCls, accordion, destroyInactivePanel, expandIcon } = this . $props ;
72
72
const newChildren = [ ] ;
73
- this . $slots . default . forEach ( ( child , index ) => {
74
- if ( isEmptyElement ( child ) ) return ;
75
- const { header, headerClass, disabled } = getPropsData ( child ) ;
76
- let isActive = false ;
77
- const key = child . key || String ( index ) ;
78
- if ( accordion ) {
79
- isActive = activeKey [ 0 ] === key ;
80
- } else {
81
- isActive = activeKey . indexOf ( key ) > - 1 ;
82
- }
73
+ if ( this . $slots . default ) {
74
+ this . $slots . default . forEach ( ( child , index ) => {
75
+ if ( isEmptyElement ( child ) ) return ;
76
+ const { header, headerClass, disabled } = getPropsData ( child ) ;
77
+ let isActive = false ;
78
+ const key = child . key || String ( index ) ;
79
+ if ( accordion ) {
80
+ isActive = activeKey [ 0 ] === key ;
81
+ } else {
82
+ isActive = activeKey . indexOf ( key ) > - 1 ;
83
+ }
83
84
84
- let panelEvents = { } ;
85
- if ( ! disabled && disabled !== '' ) {
86
- panelEvents = {
87
- itemClick : ( ) => {
88
- this . onClickItem ( key ) ;
85
+ let panelEvents = { } ;
86
+ if ( ! disabled && disabled !== '' ) {
87
+ panelEvents = {
88
+ itemClick : ( ) => {
89
+ this . onClickItem ( key ) ;
90
+ } ,
91
+ } ;
92
+ }
93
+
94
+ const props = {
95
+ props : {
96
+ header,
97
+ headerClass,
98
+ isActive,
99
+ prefixCls,
100
+ destroyInactivePanel,
101
+ openAnimation : this . currentOpenAnimations ,
102
+ accordion,
103
+ expandIcon,
104
+ } ,
105
+ on : {
106
+ ...panelEvents ,
89
107
} ,
90
108
} ;
91
- }
92
-
93
- const props = {
94
- props : {
95
- header,
96
- headerClass,
97
- isActive,
98
- prefixCls,
99
- destroyInactivePanel,
100
- openAnimation : this . currentOpenAnimations ,
101
- accordion,
102
- expandIcon,
103
- } ,
104
- on : {
105
- ...panelEvents ,
106
- } ,
107
- } ;
108
109
109
- newChildren . push ( cloneElement ( child , props ) ) ;
110
- } ) ;
110
+ newChildren . push ( cloneElement ( child , props ) ) ;
111
+ } ) ;
112
+ }
111
113
return newChildren ;
112
114
} ,
113
115
setActiveKey ( activeKey ) {
0 commit comments