瀏覽代碼

页签bug 修复

lilei 4 年之前
父節點
當前提交
763dc44b6b
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/components/MultiTab/MultiTab.vue

+ 7 - 1
src/components/MultiTab/MultiTab.vue

@@ -123,13 +123,19 @@ export default {
   watch: {
   watch: {
     '$route': function (newVal) {
     '$route': function (newVal) {
       this.activeKey = newVal.name
       this.activeKey = newVal.name
-      if (this.tabsList.indexOf(newVal.name) < 0) {
+      const index = this.tabsList.indexOf(newVal.name)
+      // 不存在
+      if (index < 0) {
         this.tabsList.push(newVal.name)
         this.tabsList.push(newVal.name)
         this.pages.push(newVal)
         this.pages.push(newVal)
+      } else {
+        // 已存在
+        this.pages.splice(index, 1, newVal)
       }
       }
     },
     },
     activeKey: function (newPathKey) {
     activeKey: function (newPathKey) {
       const row = this.pages.find(item => item.name == newPathKey)
       const row = this.pages.find(item => item.name == newPathKey)
+      console.log(row.fullPath)
       this.$router.push({ path: row.fullPath })
       this.$router.push({ path: row.fullPath })
     }
     }
   },
   },