From 8fc9a4eca680956ba1805c285e6450a471e652c5 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Fri, 17 Feb 2023 18:04:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D`getHistoryMode`?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=AD=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E6=9C=AA=E5=88=9D=E5=A7=8B=E5=8C=96=E5=B8=A6=E6=9D=A5=E7=9A=84?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=83=AD=E6=9B=B4=E6=96=B0=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.ts | 2 +- src/router/utils.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 25d7bf3b3..1650832a5 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -61,7 +61,7 @@ export const remainingPaths = Object.keys(remainingRouter).map(v => { /** 创建路由实例 */ export const router: Router = createRouter({ - history: getHistoryMode(), + history: getHistoryMode(import.meta.env.VITE_ROUTER_HISTORY), routes: constantRoutes.concat(...(remainingRouter as any)), strict: true, scrollBehavior(to, from, savedPosition) { diff --git a/src/router/utils.ts b/src/router/utils.ts index 68656e73f..d2a789803 100644 --- a/src/router/utils.ts +++ b/src/router/utils.ts @@ -322,8 +322,7 @@ function addAsyncRoutes(arrRoutes: Array) { } /** 获取路由历史模式 https://next.router.vuejs.org/zh/guide/essentials/history-mode.html */ -function getHistoryMode(): RouterHistory { - const routerHistory = import.meta.env.VITE_ROUTER_HISTORY; +function getHistoryMode(routerHistory): RouterHistory { // len为1 代表只有历史模式 为2 代表历史模式中存在base参数 https://next.router.vuejs.org/zh/api/#%E5%8F%82%E6%95%B0-1 const historyMode = routerHistory.split(","); const leftMode = historyMode[0];