Răsfoiți Sursa

4.0.90 当路由切换时CURD表头tab切回到第一个

liuyanpeng 1 an în urmă
părinte
comite
f28f577f64
2 a modificat fișierele cu 13 adăugiri și 5 ștergeri
  1. 1 1
      package.json
  2. 12 4
      src/window1/tabGridView/WindowTab.vue

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "name": "client-base-v4",
   "description": "Leanwo Prodog Client",
-  "version": "4.0.89",
+  "version": "4.0.90",
   "author": "yangzhijie1488 <yangzhijie1488@163.com>",
   "scripts": {
     "ins": "npm install --registry http://wuzhixin.vip:4873",

+ 12 - 4
src/window1/tabGridView/WindowTab.vue

@@ -5,7 +5,7 @@
       :key="index"
       role="presentation"
       :class="{ active: currentTabIndex === index }"
-      @click="changeTab(index,item)"
+      @click="changeTab(index, item)"
     >
       <a>{{ item.groupName }}</a>
       <span :class="{ jt: true, active: currentTabIndex === index }" />
@@ -21,7 +21,8 @@
 
 <script setup>
 import { ref, defineEmits, defineProps, watch } from 'vue';
-
+import { useRoute } from 'vue-router';
+const router = useRoute();
 const props = defineProps({
   tabProps: {
     type: Array,
@@ -32,12 +33,19 @@ const props = defineProps({
 const emits = defineEmits(['getNowTab']);
 
 const currentTabIndex = ref(0);
+watch(
+  () => router.fullPath,
+  (newPath, oldPath) => {
+    if (newPath !== oldPath) {
+      currentTabIndex.value = 0;
+    }
+  },
+);
 
-const changeTab = (index,record) => {
+const changeTab = (index, record) => {
   currentTabIndex.value = index;
   emits('getNowTab', record.groupName);
 };
-
 </script>
 
 <style scoped>