vue项目使用ts识别别名@
程序员文章站
2022-05-17 20:33:42
...
在tsconfig.json文件中加入
"paths": {
"baseUrl": ".",
"@/*": ["src/*"]
}
完整配置
//vite.config.ts
resolve: {
alias: {
'@': resolve('src'),
'*': resolve(''),
},
},
//tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"types": ["vite/client"],
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
}
上一篇: 关于C++使用指针实现冒泡法的未解决问题
下一篇: Cake HDU 1722