如何使用 Visual Studio 的 Intellisense 处理复杂的 JS 文件
简而言之,这是我的场景。
JS 文件 1 (Namespace.js):
/// <reference path="Namespace.more.js" />
var Namespace = {
property1 = 'something useful';
}
JS 文件 2 (Namespace.more.js):
Namespace.more = {
another = 'another useful thing';
}
这在实际实现中要复杂得多,但就我的目的而言,它可以很好地工作。我无法让智能感知在原始文件上正常工作。这是有道理的,它抱怨命名空间对象不存在(它不在文件开头)。
我的问题是,您将如何正确组织这些文档并获得正确的智能感知?假设不仅仅是这里描述的简单对象。
我有许多文件构建在具有原始命名空间声明的单个文件上,每个新对象都有自己的文件。
Here is my scenario, simply put.
JS File 1 (Namespace.js):
/// <reference path="Namespace.more.js" />
var Namespace = {
property1 = 'something useful';
}
JS File 2 (Namespace.more.js):
Namespace.more = {
another = 'another useful thing';
}
This is much more complex in the actual implementation, but for my purpose it'll serve fine. I cannot get the intellisense to work correctly on the original file. It makes sense, it complains the the Namespace object does not exist (which it doesn't at the start of the file).
My question is, how would you properly organize these documents, and get the correct intellisense? Assuming there is much more than just the simple object described here.
I have many files which build on a single file that has the original namespace delcaration, each new object has its own file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
是向后的。您需要在
.more
(使用它)中引用原始文件(它创建命名空间)。Your
<reference>
is backwards.You need to reference the original file (which creates the namespace) in
.more
(which uses it).