Browse Source

修复tabs关闭最后一个tab后,再次打开会保留最后一个tab bug

daxiongYang 6 years ago
parent
commit
47703701bf
1 changed files with 3 additions and 4 deletions
  1. 3 4
      src/views/main-content.vue

+ 3 - 4
src/views/main-content.vue

84
      },
84
      },
85
      // tabs, 删除tab
85
      // tabs, 删除tab
86
      removeTabHandle (tabName) {
86
      removeTabHandle (tabName) {
87
        var newTabs = this.mainTabs.filter(item => item.name !== tabName)
88
        if (newTabs.length >= 1) {
87
        this.mainTabs = this.mainTabs.filter(item => item.name !== tabName)
88
        if (this.mainTabs.length >= 1) {
89
          // 当前选中tab被删除
89
          // 当前选中tab被删除
90
          if (tabName === this.mainTabsActiveName) {
90
          if (tabName === this.mainTabsActiveName) {
91
            this.$router.push({ name: newTabs[newTabs.length - 1].name }, () => {
91
            this.$router.push({ name: this.mainTabs[this.mainTabs.length - 1].name }, () => {
92
              this.mainTabsActiveName = this.$route.name
92
              this.mainTabsActiveName = this.$route.name
93
            })
93
            })
94
          }
94
          }
95
          this.mainTabs = newTabs
96
        } else {
95
        } else {
97
          this.menuActiveName = ''
96
          this.menuActiveName = ''
98
          this.$router.push({ name: 'home' })
97
          this.$router.push({ name: 'home' })