Browse Source

fix: 修复tabs问题

Drjnigfubo 3 years ago
parent
commit
db0bda842f
1 changed files with 3 additions and 4 deletions
  1. 3 4
      src/packages/__VUE/tabs/common.ts

+ 3 - 4
src/packages/__VUE/tabs/common.ts

@@ -1,6 +1,6 @@
 import { pxCheck } from '@/packages/utils/pxCheck';
 import { pxCheck } from '@/packages/utils/pxCheck';
 import { TypeOfFun } from '@/packages/utils/util';
 import { TypeOfFun } from '@/packages/utils/util';
-import { onMounted, provide, VNode, ref, Ref, computed, onActivated, watch } from 'vue';
+import { onMounted, provide, VNode, ref, Ref, computed, onActivated, watch, nextTick } from 'vue';
 export class Title {
 export class Title {
   title: string = '';
   title: string = '';
   titleSlot?: VNode[];
   titleSlot?: VNode[];
@@ -64,9 +64,8 @@ export const component = {
     provide('activeKey', { activeKey: computed(() => props.modelValue) });
     provide('activeKey', { activeKey: computed(() => props.modelValue) });
     provide('autoHeight', { autoHeight: computed(() => props.autoHeight) });
     provide('autoHeight', { autoHeight: computed(() => props.autoHeight) });
     const titles: Ref<Title[]> = ref([]);
     const titles: Ref<Title[]> = ref([]);
-
     const renderTitles = (vnodes: VNode[]) => {
     const renderTitles = (vnodes: VNode[]) => {
-      vnodes.forEach((vnode: VNode, index: number) => {
+      vnodes?.forEach((vnode: VNode, index: number) => {
         let type = vnode.type;
         let type = vnode.type;
         type = (type as any).name || type;
         type = (type as any).name || type;
         if (type == 'nut-tabpane') {
         if (type == 'nut-tabpane') {
@@ -105,9 +104,9 @@ export const component = {
         currentIndex.value = index;
         currentIndex.value = index;
       }
       }
     };
     };
-
     const init = (vnodes: VNode[] = slots.default?.()) => {
     const init = (vnodes: VNode[] = slots.default?.()) => {
       titles.value = [];
       titles.value = [];
+      vnodes = vnodes.filter((item) => typeof item.children !== 'string');
       if (vnodes && vnodes.length) {
       if (vnodes && vnodes.length) {
         renderTitles(vnodes);
         renderTitles(vnodes);
       }
       }