Explorar el Código

解决路由循环问题

yuhan hace 7 meses
padre
commit
efca569ac6
Se han modificado 1 ficheros con 23 adiciones y 10 borrados
  1. 23 10
      src/permission.js

+ 23 - 10
src/permission.js

@@ -78,13 +78,20 @@ router.beforeEach((to, from, next) => {
           })
         } else {
           // next()
-          console.log(from, to)
+          // console.log(from, to)
+          // console.log(from.meta.replace)
           // 从添加页面跳转其他页面后需要删除联锁添加页面
-          if(from.path === '/interLock/summary/set' && !from.meta.replace){
+          if(from.path === '/interLock/summary/set'){
             // 为了解决循环设置了replace
-            from.meta.replace = true
-            next({ ...to, replace: true })
-            from.meta.replace = false
+            if(!from.meta.replace){
+              from.meta.replace = true
+              next({ ...to, replace: true })
+            } else {
+              from.meta.replace = false
+            }
+            // console.log(11111)
+            // console.log(from)
+            // from.meta.replace = false
           } else {
             next()
           }
@@ -157,13 +164,19 @@ router.beforeEach((to, from, next) => {
               })
             })
         } else {
-          console.log(from, to)
+          // console.log(from, to)
           // 从添加页面跳转其他页面后需要删除联锁添加页面
-          if(from.path === '/interLock/summary/set' && !from.meta.replace){
+          if(from.path === '/interLock/summary/set'){
             // 为了解决循环设置了replace
-            from.meta.replace = true
-            next({ ...to, replace: true })
-            from.meta.replace = false
+            // from.meta.replace = true
+            // next({ ...to, replace: true })
+            // from.meta.replace = false
+            if(!from.meta.replace){
+              from.meta.replace = true
+              next({ ...to, replace: true })
+            } else {
+              from.meta.replace = false
+            }
           } else {
             next()
           }