瀏覽代碼

ignore NavigationDuplicated error

Michael Wang 5 年之前
父節點
當前提交
1c89af5c16
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      src/router.js

+ 13 - 0
src/router.js

@@ -10,6 +10,19 @@ import PrintRoutes from "./modules/print/routes/routes";
 import ReportsRoutes from "./modules/reports/routes/routes";
 import { CORE_API } from "@/constants/constants.js";
 
+// 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);
 
 let router = new Router({