wolyshaw 4 years ago
parent
commit
1197afb469
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/components/tabs/index.vue

+ 12 - 1
src/components/tabs/index.vue

@@ -16,11 +16,21 @@ export default {
     return {
       active: '',
       panels: [],
+      panelsByName: {}
     }
   },
   methods: {
     getAllPanel() {
-      this.panels = this.$slots.default.filter(item => item.tag && item.tag.indexOf('ElTabPane') > -1)
+      this.panels = this.$slots.default.filter(item => {
+        const isPanel = item.tag && item.tag.indexOf('ElTabPane') > -1
+        const data = {}
+        if (isPanel && item.child) {
+          data[item.child.name] = item.child
+          item.child.$slots = {}
+          console.log(item)
+        }
+        return isPanel
+      })
     },
     tab(item) {
       this.$router.replace({
@@ -41,6 +51,7 @@ export default {
   },
   mounted() {
     this.getAllPanel()
+    console.log(this.panelsByName)
     if (this.panels.length) {
       this.active = this.$route.query[this.searchKey] || this.panels[0].child?.name
     }