mirror of
https://github.com/sunniejs/vue-h5-template.git
synced 2026-05-21 18:28:12 +08:00
515 B
515 B
alias
项目在 vite.config.mts 中配置了路径别名,方便引用 src 和 types 目录下的文件:
import { fileURLToPath, URL } from 'node:url';
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'#': fileURLToPath(new URL('./types', import.meta.url))
},
},
使用示例:
// 引用 src 下的文件
import { http } from '@/utils/request';
// 引用 types 下的类型
import type { UserInfo } from '#/index';