use createWebHistory

This commit is contained in:
midfar 2023-03-16 09:32:00 +08:00
parent a07fad8e28
commit 23308985d5
3 changed files with 6 additions and 5 deletions

1
auto-imports.d.ts vendored
View File

@ -3,5 +3,4 @@ export {}
declare global {
const ElMessage: typeof import('element-plus/es')['ElMessage']
const ElMessageBox: typeof import('element-plus/es')['ElMessageBox']
const ElNotification: typeof import('element-plus/es')['ElNotification']
}

View File

@ -1,5 +1,5 @@
import { markRaw } from 'vue';
import { createRouter, createWebHashHistory } from 'vue-router'; // createWebHashHistory, createWebHistory
import { createRouter, createWebHistory } from 'vue-router'; // createWebHashHistory, createWebHistory
import type { Router, RouteRecordRaw, RouteComponent } from 'vue-router';
import { Help as IconHelp } from '@element-plus/icons-vue';
@ -393,11 +393,13 @@ export const asyncRoutes:RouteRecordRaw[] = [
{ path: '/:pathMatch(.*)*', redirect: '/404', meta: { hidden: true }}
];
console.log('BASE_URL=', import.meta.env);
const createTheRouter = ():Router => createRouter({
history: createWebHashHistory(import.meta.env.BASE_URL),
// history: createWebHashHistory(import.meta.env.BASE_URL),
// 注意,如果要配置 HTML5 模式则需要修改nginx配置参考资料
// https://router.vuejs.org/zh/guide/essentials/history-mode.html
// history: createWebHistory(import.meta.env.BASE_URL),
history: createWebHistory(import.meta.env.BASE_URL),
scrollBehavior: () => ({ top: 0 }),
routes: constantRoutes
});

View File

@ -20,7 +20,7 @@ export default defineConfig(({ command, mode }) => {
const prodMock = true;
return {
base: './', // 注意,必须以"/"结尾
base: '/', // 注意,必须以"/"结尾BASE_URL配置
define: {
'process.env': env
},