소스 검색

MultiTab bug修复

chenrui 3 년 전
부모
커밋
03fef29837
1개의 변경된 파일9개의 추가작업 그리고 3개의 파일을 삭제
  1. 9 3
      src/components/MultiTab/MultiTab.vue

+ 9 - 3
src/components/MultiTab/MultiTab.vue

@@ -122,9 +122,11 @@ export default {
   },
   watch: {
     '$route': function (newVal, oldVal) {
-      // 父页面(列表)进入子页面(编辑、详情)再返回至父页面时关闭子页面页签
+      // 父页面(列表)进入子页面(编辑、详情)再返回至父页面时关闭子页面页签   子页面点击“返回列表”
       if (oldVal && oldVal.name && newVal.query.closeLastOldTab) {
-        this.remove(oldVal.name) // 关闭子页面
+        if (oldVal.name.indexOf('List') == -1) { // 要关闭的页面不能是列表页
+          this.remove(oldVal.name) // 关闭子页面
+        }
       }
       this.activeKey = newVal.name
       const index = this.tabsList.indexOf(newVal.name)
@@ -139,7 +141,11 @@ export default {
     activeKey: function (newPathKey) {
       const row = this.pages.find(item => item.name == newPathKey)
       // console.log(row.fullPath)
-      this.$router.push({ path: row.fullPath })
+      if (row.fullPath.indexOf('/list') == -1) {
+        this.$router.push({ path: row.fullPath })
+      } else {
+        this.$router.push({ path: row.fullPath, query: { closeLastOldTab: true } })
+      }
     }
   },
   render () {