From afe42599a9bddac416f3750fb47a30a85cd37bab Mon Sep 17 00:00:00 2001 From: luffy <823937011@qq.com> Date: Thu, 17 Oct 2024 16:06:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(space):=20=E4=BF=AE=E5=A4=8Dt-space?= =?UTF-8?q?=E5=9C=A8=E5=B5=8C=E5=A5=97=E4=BD=BF=E7=94=A8=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=BD=BF=E7=94=A8v-if=E9=9A=90=E8=97=8F=E4=BC=9A=E4=BA=A7?= =?UTF-8?q?=E7=94=9F=E5=86=97=E4=BD=99=E7=A9=BA=E6=A0=BC=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/_common | 2 +- src/space/_example/combination.vue | 18 ++++++++++++++++++ src/space/space.tsx | 24 +++++++++++++----------- 3 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 src/space/_example/combination.vue diff --git a/src/_common b/src/_common index fdf8357788..4bdf9ced2d 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit fdf83577887894362b0cc792149a5e4d30b968e8 +Subproject commit 4bdf9ced2d0b1c3aaf88c035424ef2230d71f396 diff --git a/src/space/_example/combination.vue b/src/space/_example/combination.vue new file mode 100644 index 0000000000..9ea599bac2 --- /dev/null +++ b/src/space/_example/combination.vue @@ -0,0 +1,18 @@ + diff --git a/src/space/space.tsx b/src/space/space.tsx index c7dcd2c951..c7c7836a4a 100644 --- a/src/space/space.tsx +++ b/src/space/space.tsx @@ -1,4 +1,4 @@ -import { defineComponent, computed, CSSProperties, Fragment } from 'vue'; +import { defineComponent, computed, CSSProperties, Fragment, Comment, isVNode } from 'vue'; import props from './props'; import { usePrefixClass } from '../hooks/useConfig'; import { useTNodeJSX } from '../hooks/tnode'; @@ -57,16 +57,18 @@ export default defineComponent({ function renderChildren() { const children = getChildSlots(); const separatorContent = renderTNodeJSX('separator'); - return children.map((child, index) => { - // filter last child - const showSeparator = index + 1 !== children.length && separatorContent; - return ( - -
{child}
- {showSeparator &&
{separatorContent}
} -
- ); - }); + return children + .filter((child) => (isVNode(child) ? child.type !== Comment : true)) + .map((child, index) => { + // filter last child + const showSeparator = index + 1 !== children.length && separatorContent; + return ( + +
{child}
+ {showSeparator &&
{separatorContent}
} +
+ ); + }); } return () => {