refactor(router): 将路由历史模式从createWebHistory更改为createWebHashHistory
为了确保在部署时路由能正确解析路径,将路由历史模式从createWebHistory更改为createWebHashHistory。这种模式更适合某些部署环境,特别是当服务器配置不支持前端路由时。
Showing
1 changed file
with
3 additions
and
3 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2025-03-20 20:36:36 | 2 | * @Date: 2025-03-20 20:36:36 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-03-21 15:45:42 | 4 | + * @LastEditTime: 2025-03-21 15:59:36 |
| 5 | * @FilePath: /mlaj/src/router/index.js | 5 | * @FilePath: /mlaj/src/router/index.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| 8 | -import { createRouter, createWebHistory } from 'vue-router' | 8 | +import { createRouter, createWebHashHistory } from 'vue-router' |
| 9 | import checkinRoutes from './checkin' | 9 | import checkinRoutes from './checkin' |
| 10 | 10 | ||
| 11 | const routes = [ | 11 | const routes = [ |
| ... | @@ -125,7 +125,7 @@ const routes = [ | ... | @@ -125,7 +125,7 @@ const routes = [ |
| 125 | ] | 125 | ] |
| 126 | 126 | ||
| 127 | const router = createRouter({ | 127 | const router = createRouter({ |
| 128 | - history: createWebHistory(import.meta.env.VITE_BASE || '/'), | 128 | + history: createWebHashHistory(import.meta.env.VITE_BASE || '/'), |
| 129 | routes, | 129 | routes, |
| 130 | scrollBehavior(to, from, savedPosition) { | 130 | scrollBehavior(to, from, savedPosition) { |
| 131 | // 每次路由切换后,页面滚动到顶部 | 131 | // 每次路由切换后,页面滚动到顶部 | ... | ... |
-
Please register or login to post a comment