@@ -138,7 +138,6 @@ const CTable = defineComponent({
138
138
*/
139
139
footer : {
140
140
type : Array as PropType < FooterItem [ ] | string [ ] > ,
141
- default : ( ) => [ ] ,
142
141
required : false ,
143
142
} ,
144
143
/**
@@ -158,7 +157,6 @@ const CTable = defineComponent({
158
157
*/
159
158
items : {
160
159
type : Array as PropType < Item [ ] > ,
161
- default : ( ) => [ ] ,
162
160
required : false ,
163
161
} ,
164
162
responsive : {
@@ -228,7 +226,7 @@ const CTable = defineComponent({
228
226
if ( typeof column === 'object' ) return column . key
229
227
else return column
230
228
} )
231
- : Object . keys ( props . items [ 0 ] || { } ) . filter ( ( el ) => el . charAt ( 0 ) !== '_' ) ,
229
+ : Object . keys ( ( props . items && props . items [ 0 ] ) || { } ) . filter ( ( el ) => el . charAt ( 0 ) !== '_' ) ,
232
230
)
233
231
234
232
const table = ( ) =>
@@ -301,34 +299,37 @@ const CTable = defineComponent({
301
299
{ } ,
302
300
{
303
301
default : ( ) => [
304
- props . items . map ( ( item : Item ) =>
305
- h (
306
- CTableRow ,
307
- {
308
- ...( item . _props && { ...item . _props } ) ,
309
- } ,
310
- {
311
- default : ( ) => [
312
- rawColumnNames . value . map (
313
- ( colName : string ) =>
314
- item [ colName ] &&
315
- h (
316
- CTableDataCell ,
317
- {
318
- ...( item . _cellProps &&
319
- item . _cellProps [ 'all' ] && { ...item . _cellProps [ 'all' ] } ) ,
320
- ...( item . _cellProps &&
321
- item . _cellProps [ colName ] && { ...item . _cellProps [ colName ] } ) ,
322
- } ,
323
- {
324
- default : ( ) => item [ colName ] ,
325
- } ,
326
- ) ,
327
- ) ,
328
- ] ,
329
- } ,
302
+ props . items &&
303
+ props . items . map ( ( item : Item ) =>
304
+ h (
305
+ CTableRow ,
306
+ {
307
+ ...( item . _props && { ...item . _props } ) ,
308
+ } ,
309
+ {
310
+ default : ( ) => [
311
+ rawColumnNames . value . map (
312
+ ( colName : string ) =>
313
+ item [ colName ] &&
314
+ h (
315
+ CTableDataCell ,
316
+ {
317
+ ...( item . _cellProps &&
318
+ item . _cellProps [ 'all' ] && { ...item . _cellProps [ 'all' ] } ) ,
319
+ ...( item . _cellProps &&
320
+ item . _cellProps [ colName ] && {
321
+ ...item . _cellProps [ colName ] ,
322
+ } ) ,
323
+ } ,
324
+ {
325
+ default : ( ) => item [ colName ] ,
326
+ } ,
327
+ ) ,
328
+ ) ,
329
+ ] ,
330
+ } ,
331
+ ) ,
330
332
) ,
331
- ) ,
332
333
] ,
333
334
} ,
334
335
) ,
@@ -346,17 +347,19 @@ const CTable = defineComponent({
346
347
{ } ,
347
348
{
348
349
default : ( ) => [
349
- props . footer . map ( ( item : FooterItem | string ) =>
350
- h (
351
- CTableDataCell ,
352
- {
353
- ...( typeof item === 'object' && item . _props && { ...item . _props } ) ,
354
- } ,
355
- {
356
- default : ( ) => ( typeof item === 'object' ? item . label : item ) ,
357
- } ,
350
+ props . footer &&
351
+ props . footer . map ( ( item : FooterItem | string ) =>
352
+ h (
353
+ CTableDataCell ,
354
+ {
355
+ ...( typeof item === 'object' &&
356
+ item . _props && { ...item . _props } ) ,
357
+ } ,
358
+ {
359
+ default : ( ) => ( typeof item === 'object' ? item . label : item ) ,
360
+ } ,
361
+ ) ,
358
362
) ,
359
- ) ,
360
363
] ,
361
364
} ,
362
365
) ,
0 commit comments