【问题标题】:VS Code, React project, intellisense when using absolute import paths使用绝对导入路径时的 VS Code、React 项目、智能感知
【发布时间】:2021-08-14 13:22:01
【问题描述】:

在我使用时的反应项目中:

//package.json
"name": "app"

那么智能感知不适用于绝对路径导入

//SomeComponent.js
import {StorageKeys} from 'app/Constants' // inellisense dont work
import {StorageKeys} from '../../Constants' // intellisense works

尝试了一些关于“jsconfig.json”和设置编译器基本网址的建议,但没有成功。 有什么想法吗?

【问题讨论】:

    标签: reactjs visual-studio-code components intellisense absolute-path


    【解决方案1】:

    好的,又是 RTFM 和 RTFM。

    {
      "compilerOptions": {
          "target": "ES6",
          "baseUrl": "./",
          "paths" : {
            "app/*" : ["./*"]
          }
      },
      "exclude": [
          "node_modules",
          "**/node_modules/*"
      ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-11
      • 2019-12-08
      • 1970-01-01
      • 2017-06-06
      相关资源
      最近更新 更多