【问题标题】:Why do I get Intellisense in vscode when using `require` but not when using `import`为什么我在使用`require`时在vscode中获得Intellisense,但在使用`import`时却没有
【发布时间】:2016-08-02 08:29:03
【问题描述】:

在 VS Code 中,当我使用 import $ from 'jquery'; 导入 jquery 时,Intellisense 无法正常工作。这是我得到的:

但是,当使用 require 语法时,const $ = require('jquery');,Intellisense 确实有效:

这种情况发生在任何类型的导入中,不仅仅是 jquery。

在使用导入语法时,有什么方法可以让 Intellisense 工作?我正在使用打字。

【问题讨论】:

    标签: visual-studio-code javascript-intellisense


    【解决方案1】:

    这是已知的错误。 https://github.com/Microsoft/vscode-react-native/issues/61

    修复已在Insiders build 中可用。或者你可以等待稳定版 1.0,这将在几天后发布。

    【讨论】:

      【解决方案2】:

      从版本 1(2016 年 4 月 14 日发布)开始,您需要在项目的根目录中创建一个包含以下内容的 jsconfig.json 文件,以便使用 import 语法启用 Intellisense:

      "compilerOptions": {
          "target": "ES6",
          "allowSyntheticDefaultImports": true
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-14
        • 1970-01-01
        • 1970-01-01
        • 2010-10-15
        • 2017-04-24
        相关资源
        最近更新 更多