11import type { PropType , ExtractPropTypes , CSSProperties } from 'vue' ;
2- import { defineComponent , computed , ref , watch } from 'vue' ;
2+ import { defineComponent , computed , ref , watch , Fragment } from 'vue' ;
33import PropTypes from '../_util/vue-types' ;
44import { filterEmpty } from '../_util/props-util' ;
55import type { SizeType } from '../config-provider' ;
@@ -80,8 +80,8 @@ const Space = defineComponent({
8080 } ) ;
8181 return ( ) => {
8282 const { wrap, direction = 'horizontal' } = props ;
83-
84- const items = filterEmpty ( slots . default ?. ( ) ) ;
83+ const children = slots . default ?. ( ) ;
84+ const items = filterEmpty ( children ) ;
8585 const len = items . length ;
8686
8787 if ( len === 0 ) {
@@ -94,6 +94,7 @@ const Space = defineComponent({
9494 return (
9595 < div class = { cn . value } style = { style . value } >
9696 { items . map ( ( child , index ) => {
97+ const originIndex = children . indexOf ( child ) ;
9798 let itemStyle : CSSProperties = { } ;
9899 if ( ! supportFlexGap . value ) {
99100 if ( direction === 'vertical' ) {
@@ -111,7 +112,7 @@ const Space = defineComponent({
111112 }
112113
113114 return (
114- < >
115+ < Fragment key = { originIndex } >
115116 < div class = { itemClassName } style = { itemStyle } >
116117 { child }
117118 </ div >
@@ -120,7 +121,7 @@ const Space = defineComponent({
120121 { split }
121122 </ span >
122123 ) }
123- </ >
124+ </ Fragment >
124125 ) ;
125126 } ) }
126127 </ div >
0 commit comments