1.Vs code商店搜索 Path Intellisense 插件安装
2. 打开设置 - 首选项 - 搜索 Path Intellisense - 打开 settings.json ,添加:
"path-intellisense.mappings": {
"@": "${workspaceRoot}/src"
}
3.项目根目录创建 jsconfig.json 文件,添加如下代码:
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
},
"exclude": [
"node_modules"
]
}
4.重启项目即可