@@ -138,7 +138,6 @@ const CTable = defineComponent({
138138 */
139139 footer : {
140140 type : Array as PropType < FooterItem [ ] | string [ ] > ,
141- default : ( ) => [ ] ,
142141 required : false ,
143142 } ,
144143 /**
@@ -158,7 +157,6 @@ const CTable = defineComponent({
158157 */
159158 items : {
160159 type : Array as PropType < Item [ ] > ,
161- default : ( ) => [ ] ,
162160 required : false ,
163161 } ,
164162 responsive : {
@@ -228,7 +226,7 @@ const CTable = defineComponent({
228226 if ( typeof column === 'object' ) return column . key
229227 else return column
230228 } )
231- : Object . keys ( props . items [ 0 ] || { } ) . filter ( ( el ) => el . charAt ( 0 ) !== '_' ) ,
229+ : Object . keys ( ( props . items && props . items [ 0 ] ) || { } ) . filter ( ( el ) => el . charAt ( 0 ) !== '_' ) ,
232230 )
233231
234232 const table = ( ) =>
@@ -301,34 +299,37 @@ const CTable = defineComponent({
301299 { } ,
302300 {
303301 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+ ) ,
330332 ) ,
331- ) ,
332333 ] ,
333334 } ,
334335 ) ,
@@ -346,17 +347,19 @@ const CTable = defineComponent({
346347 { } ,
347348 {
348349 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+ ) ,
358362 ) ,
359- ) ,
360363 ] ,
361364 } ,
362365 ) ,
0 commit comments