vue配置別名
vite.config.ts
export default defineConfig(
...
resolve:{
alias:{
"@":path.resolve(__dirname,"src"),
"com":path.resolve(__dirname,"src/components"),
}
},
...
})
ts配置
tsconfig.app.json 如果沒有那就tsconfig.json
"compilerOptions": {
...
/* 支援別名@ */
"paths": {
"@":["./src"],
"@/*":["./src/*"]
}
...
}
支援vue元件
https://www.cnblogs.com/skyvip/p/18264252
vite-env.d.ts
declare module '*.vue' {
import { DefineComponent } from "vue"
const component: DefineComponent<{}, {}, any>
export default component
}