From eb975ee73d53d460c8242f022e2e5e9de8a2a01e Mon Sep 17 00:00:00 2001
From: wyy <3234929097@qq.com>
Date: Mon, 20 Mar 2023 17:37:26 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=B7=AF=E7=94=B1=E9=87=8D?=
=?UTF-8?q?=E5=A4=8D=E8=B7=B3=E8=BD=AC=E6=8A=A5=E9=94=99&=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=E7=89=88=E6=9C=AC=E5=8F=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/index.html | 2 +-
src/router/index.js | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/public/index.html b/public/index.html
index aad42d9..fe4951b 100644
--- a/public/index.html
+++ b/public/index.html
@@ -7,7 +7,7 @@
<%= htmlWebpackPlugin.options.title %>
diff --git a/src/router/index.js b/src/router/index.js
index 1a16fda..9fbf412 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -12,6 +12,17 @@ import { isURL } from '@/utils/validate'
import { clearLoginInfo } from '@/utils'
Vue.use(Router)
+// 解决路由重复跳转报错
+const originalPush = Router.prototype.push
+const originalReplace = Router.prototype.replace
+// 修改原型对象中的push函数
+Router.prototype.push = function push (location) {
+ return originalPush.call(this, location).catch(err => err)
+}
+// 修改原型对象中的replace函数
+Router.prototype.replace = function replace (location) {
+ return originalReplace.call(this, location).catch(err => err)
+}
// 开发环境不使用懒加载, 因为懒加载页面太多的话会造成webpack热更新太慢, 所以只有生产环境使用懒加载
const _import = require('./import-' + process.env.NODE_ENV)