Sfoglia il codice sorgente

vue-router NavigationDuplicated

Michael Wang 5 anni fa
parent
commit
f62cb5f501
1 ha cambiato i file con 13 aggiunte e 0 eliminazioni
  1. 13 0
      src/router/index.js

+ 13 - 0
src/router/index.js

@@ -4,6 +4,19 @@ import Vue from "vue";
 import Router from "vue-router";
 import Home from "../views/Home.vue";
 
+// ignore NavigationDuplicated. https://github.com/vuejs/vue-router/issues/2881
+const originalPush = Router.prototype.push;
+Router.prototype.push = function push(location, onResolve, onReject) {
+  if (onResolve || onReject)
+    return originalPush.call(this, location, onResolve, onReject);
+  try {
+    return originalPush.call(this, location).catch(err => err);
+  } catch (error) {
+    console.log(error);
+  }
+};
+// end ignore
+
 Vue.use(Router);
 
 // function propsValidator(route, component) {