系统路径别名配置以及路径提示

This commit is contained in:
huangge1199 2024-11-28 10:01:56 +08:00
parent 6df44e6aaf
commit 3caa9d2429
5 changed files with 19 additions and 4 deletions

View File

@ -10,6 +10,7 @@
}, },
"dependencies": { "dependencies": {
"@element-plus/icons-vue": "^2.3.1", "@element-plus/icons-vue": "^2.3.1",
"@types/node": "^22.10.0",
"element-plus": "^2.8.8", "element-plus": "^2.8.8",
"vue": "^3.5.13", "vue": "^3.5.13",
"vue-router": "^4.5.0" "vue-router": "^4.5.0"

View File

@ -4,12 +4,12 @@ const routes: RouteRecordRaw[] = [
{ {
path: '/login', path: '/login',
name: 'Login', name: 'Login',
component: ()=>import('../views/login/index.vue') component: ()=>import('@/views/login/index.vue')
}, },
{ {
path: '/:pathMatch(.*)*', path: '/:pathMatch(.*)*',
name: '404', name: '404',
component: ()=>import('../views/error/404.vue') component: ()=>import('@/views/error/404.vue')
}, },
] ]
const router: Router = createRouter({ const router: Router = createRouter({

View File

@ -21,7 +21,11 @@
"noUnusedParameters": true, "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true, "noUncheckedSideEffectImports": true,
"types": ["element-plus/global"] "types": ["element-plus/global"],
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}, },
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
} }

View File

@ -19,7 +19,11 @@
"noUnusedParameters": true, "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true, "noUncheckedSideEffectImports": true,
"types": ["element-plus/global"] "types": ["element-plus/global"],
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}, },
"include": ["vite.config.ts"] "include": ["vite.config.ts"]
} }

View File

@ -1,7 +1,13 @@
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [vue()], plugins: [vue()],
resolve: {
alias: {
'@': resolve(__dirname, 'src')
}
}
}) })