From ff4b4a460397e29a6634f8cc7da09c6cdb143bec Mon Sep 17 00:00:00 2001 From: 07akioni <07akioni2@gmail.com> Date: Sat, 5 Jun 2021 00:44:56 +0800 Subject: [PATCH] fix(tabs): throw error with default slot --- src/tabs/src/Tabs.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/tabs/src/Tabs.tsx b/src/tabs/src/Tabs.tsx index 94cd42e93..6058029d5 100644 --- a/src/tabs/src/Tabs.tsx +++ b/src/tabs/src/Tabs.tsx @@ -116,9 +116,8 @@ export default defineComponent({ const barElRef = ref(null) const scrollWrapperElRef = ref(null) const addTabInstRef = ref(null) - const xScrollInstRef = ref<(VXScrollInst & ComponentPublicInstance) | null>( - null - ) + const xScrollInstRef = + ref<(VXScrollInst & ComponentPublicInstance) | null>(null) const leftReachedRef = ref(true) const rightReachedRef = ref(true) @@ -128,9 +127,11 @@ export default defineComponent({ const uncontrolledValueRef = ref( compitableValueRef.value ?? props.defaultValue ?? - ((flatten((slots as any).default())[0] as any).props.name as - | string - | number) + (slots.default + ? ((flatten((slots as any).default())[0] as any).props.name as + | string + | number) + : null) ) const mergedValueRef = useMergedState( compitableValueRef, @@ -492,7 +493,7 @@ export default defineComponent({ function filterMapTabPanes ( tabPaneVNodes: VNode[], - value: string | number | undefined + value: string | number | null ): VNode[] { const children: VNode[] = [] tabPaneVNodes.forEach((vNode) => {