- 前端项目通常会用
@/
来做为别名,映射路径src/
- 别名缺点:在引用文件的时候,无法通过
.
来唤起路径提示 - 在项目根目录下,添加一个jsconfig.json文件,内容如下
- 解决vscode使用了@别名后路径不提示的问题
- jsconfig.json配置参考 https://code.visualstudio.com/docs/languages/jsconfig
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"baseUrl": "./",
"paths": {
"@@/*": ["./*"],
"@/*": ["src/*"],
"@assets/*": ["src/assets/*"],
"@constants/*": ["src/constants/*"],
"@components/*": ["src/components/*"],
"@hooks/*": ["src/hooks/*"],
"@routes/*": ["src/routes/*"],
"@models/*": ["src/models/*"],
"@locales/*": ["src/locales/*"],
"@utils/*": ["src/utils/*"]
},
"target": "ES6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "build"]
}