From dedcdc65b6e3ced6d684556387dfd7cc161d03fd Mon Sep 17 00:00:00 2001 From: kousum Date: Wed, 17 Apr 2024 10:33:46 +0800 Subject: [PATCH] fix: [Breadcrumb] routes from children --- packages/semi-ui-vue/src/App.tsx | 4 ++-- .../components/breadcrumb/__test__/BreadcrumbDemo.tsx | 11 ++++++++++- .../semi-ui-vue/src/components/breadcrumb/index.tsx | 6 +++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/semi-ui-vue/src/App.tsx b/packages/semi-ui-vue/src/App.tsx index 5cf7dc72..4c1aa31b 100755 --- a/packages/semi-ui-vue/src/App.tsx +++ b/packages/semi-ui-vue/src/App.tsx @@ -176,7 +176,7 @@ const App = defineComponent((props, {slots}) => { {/**/} {/**/} {/**/} - + {/**/} {/**/} {/**/} {/**/} @@ -184,7 +184,7 @@ const App = defineComponent((props, {slots}) => { {/**/} {/**/} {/**/} - {/**/} + {/**/} {/**/} {/**/} diff --git a/packages/semi-ui-vue/src/components/breadcrumb/__test__/BreadcrumbDemo.tsx b/packages/semi-ui-vue/src/components/breadcrumb/__test__/BreadcrumbDemo.tsx index e51b2996..ed53eb01 100644 --- a/packages/semi-ui-vue/src/components/breadcrumb/__test__/BreadcrumbDemo.tsx +++ b/packages/semi-ui-vue/src/components/breadcrumb/__test__/BreadcrumbDemo.tsx @@ -1,4 +1,4 @@ -import {defineComponent, ref, h, Fragment} from 'vue' +import { defineComponent, ref, h, Fragment, onMounted } from 'vue'; import Breadcrumb, {BreadcrumbItem} from "../index"; import {IconArticle, IconHome} from "@kousum/semi-icons-vue"; @@ -12,6 +12,12 @@ export const vuePropsType = { const BreadcrumbDemo = defineComponent((props, {slots}) => { + const routes = ref([]) + onMounted(()=>{ + setTimeout(()=>{ + routes.value = ['sd','sdsd'] + }, 3000) + }) return () => (
@@ -45,6 +51,9 @@ const BreadcrumbDemo = defineComponent((props, {slots}) => ] } /> +
) }) diff --git a/packages/semi-ui-vue/src/components/breadcrumb/index.tsx b/packages/semi-ui-vue/src/components/breadcrumb/index.tsx index 5833a48d..c5ab8371 100644 --- a/packages/semi-ui-vue/src/components/breadcrumb/index.tsx +++ b/packages/semi-ui-vue/src/components/breadcrumb/index.tsx @@ -32,7 +32,7 @@ import {IconMore} from '@kousum/semi-icons-vue'; import {AriaAttributes} from "../AriaAttributes"; import {VueJsxNode} from "../interface"; -import {getVNodeChildren} from "../_utils"; +import { getFragmentChildren, getVNodeChildren } from '../_utils'; const clsPrefix = cssClasses.PREFIX; @@ -230,9 +230,9 @@ const Breadcrumb = defineComponent((props, {}) => { } = props; const { isCollapsed } = state; const hasRoutes = routes && routes.length > 0; - const items = getVNodeChildren(((hasRoutes ? + const items = hasRoutes ? foundation.genRoutes(routes) : - children) as VNode[])); + (getFragmentChildren(slots) || []); let template;