- 在
vite.config.ts
中配置 ```typescript import { defineConfig } from ‘vite’ import vue from ‘@vitejs/plugin-vue’ // 引入path import { resolve } from ‘path’ // https://vitejs.dev/config/ export default defineConfig({ plugins: [vue()],
resolve: { // 配置别名 alias: { “@”: resolve(dirname, “src/“), “@c”: resolve(dirname, “src/components”), }, // 省略后缀 extensions: [‘.js’, ‘.jsx’, ‘.ts’] } })
在 `ts.config.json` 指定补全路径
```json
{
// 添加
"baseUrl": ".",
"paths": {
"@/*": [
"src/*"
]
},
}