VS Code Intellisense 不适用于 HTML 中的 es6 导入

问题描述 投票:0回答:0

我无法让 VS Code Intellisense 识别 .html 文件中导入模块 (es6) 中的代码。

//module1.js
class A{
  B(){
    console.log("Hello, World")
  }
}
export default A;
<html><body><script type="module">
  import A from "./module1.js"
  let a = new A();
  a.B() 
  //I would expect Intellisense to suggest B() after typing a., but it does not.
</script></body></html>

我在禁用所有扩展的 MacOS 上使用 VS Code 1.76.1。 如果我将 module1 更改为

export {A}
,我会遇到同样的问题。我试过使用
jsconfig.json
文件,但没有任何变化。

值得注意的是,当我从另一个 js 文件导入 module1.js 时,VS Code 正确地提供了建议:

//test.js
import A from "./module.js"
let a = new A();
a.B()

...这将我的问题与 VSCode Intellisense not fully working with ES6 imports 区分开来?.

我也没有使用 ts,这与 How to get intellisense for external javascript libraries with es5 and Visual Studio Code

我已经关注了这里的主题:https://github.com/microsoft/vscode/issues/26338,但是建议的扩展不起作用:https://marketplace.visualstudio.com/items?itemName=shuaihu .html-嵌入式-javascript

visual-studio-code intellisense javascript-intellisense
© www.soinside.com 2019 - 2024. All rights reserved.