- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何在 VS Code 中为自定义 .js 文件启用智能感知? This site据说 JavaScript IntelllSense 已经可以工作,但如果您想获得有关代码完成的更多信息,可以使用
我不需要更多信息。只是想看看一些建议。例如,我在文件a.js中编写了一些函数。当我在 b.js 文件中工作时,如何启用 intellsense(引用 a.js)。
最佳答案
我曾经添加/// <reference path="ScriptFile1.js" />
在 .js 文件之上并且它可以工作,我还曾经将文件从解决方案资源管理器拖放到 js 文件中创建此引用线,但它不再在我当前的 VS 版本上工作。
更多相关信息请参见:https://msdn.microsoft.com/en-us/library/bb385682.aspx
Reference Directives
A reference directive enables Visual Studio to establish a relationship between the script you are currently editing and other scripts.
The reference directive lets you include a script file in the scripting context of the current script file. This enables IntelliSense to reference externally defined functions, types, and fields as you code. You create a reference directive in the form of an XML comment.
The directive must be declared earlier in the file than any script.A reference directive can include a disk-based script reference, an assembly-based script reference, a service-based script reference, or a page-based script reference.
The following example shows examples of using disk-based reference directives. In the first example, the language service looks for the file in the same folder that contains the project file (for example, .jsproj).
/// <reference path="ScriptFile1.js" />
/// <reference path="Scripts/ScriptFile2.js"/>
/// <reference path="../ScriptFile3.js" />
/// <reference path="~/Scripts/ScriptFile4.js" />
此外,这篇文章也值得阅读以获得其他一些想法:https://madskristensen.net/post/the-story-behind-_referencesjs
关于javascript - 如何在 VS Code 中启用智能感知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45936904/
我是一名优秀的程序员,十分优秀!