فهرست منبع

Menu: fix router NavigationDuplicated error when using vue-router@^3.1.0 (#17269)

* Menu: fix router NavigationDuplicated error when using vue-router@^3.1.0

* Better fix

* comment

* fix
iamkun 5 سال پیش
والد
کامیت
df3562d905
1فایلهای تغییر یافته به همراه6 افزوده شده و 1 حذف شده
  1. 6 1
      packages/menu/src/menu.vue

+ 6 - 1
packages/menu/src/menu.vue

@@ -271,7 +271,12 @@
         if (this.router && hasIndex) {
         if (this.router && hasIndex) {
           this.routeToItem(item, (error) => {
           this.routeToItem(item, (error) => {
             this.activeIndex = oldActiveIndex;
             this.activeIndex = oldActiveIndex;
-            if (error) console.error(error);
+            if (error) {
+              // vue-router 3.1.0+ push/replace cause NavigationDuplicated error 
+              // https://github.com/ElemeFE/element/issues/17044
+              if (error.name === 'NavigationDuplicated') return
+              console.error(error)
+            }
           });
           });
         }
         }
       },
       },