我无法让 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 不完全适用于 ES6 导入的问题区分开来?.
我也没有使用 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-embedded -javascript