简体   繁体   English

如何将 vscode Ctrl+Click go 设置为具有别名功能的定义文件

[英]how to set vscode Ctrl+Click go to definition file with alias feature

I used to implement alias feature, like this:我曾经实现别名功能,像这样:

resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },

but this feature let vscode can't go to definition file by Ctrl+Click .但是这个特性让 vscode 不能通过Ctrl+Click go 来定义文件。 How to fix this?如何解决这个问题?

Create or edit a jsconfig.json / tsconfig.json file at the root of your project and add the "paths" option:在项目的根目录下创建或编辑jsconfig.json / tsconfig.json文件并添加“路径”选项:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

Docs 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM