在使用VS Code开发Vue项目时,可能会遇到无法跳转到 @/path 的问题。以下是解决方法。

在前端项目的目录下增加jsconfig.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"compilerOptions": {
"target": "es6",
"baseUrl": ".",
"paths": {
"@/*": [
"src/*"
]
}
},
"exclude": [
"node_modules",
"dist"
],
"include": [
"src/**/*"
]
}

具体的用法在这里

如果你的工程中前端目录并不在根目录,则需要在vetur.config.js中指定项目,就像下面这样。

1
2
3
4
5
module.exports = {
projects: [
"./frontend"
]
}

作为参考,我的工程目录长这样:

1
2
3
4
5
|--backend/
|--frontend/
| |--src/
| |--jsconfig.js
|--vetur.config.js

Reference