如何在VS2010中为javascript IntelliSense引用多个文件
我有一个大型解决方案,包含大约 40 个单独的 javascript 文件,这些文件通过特殊的 js 服务引用网页。我想在 VS2010 中使用新的 IntelliSense 功能,但是很难
/// <reference path="../../lib/jquery-1.3.2.js" />
向解决方案中的每个 js 文件 添加大约 40 个这样的单独引用:也许有某种方法可以引用文件夹中的所有文件?我尝试过这样的事情:
/// <reference path="../../lib/*.*" />
但它不起作用...... 谢谢。
更新: 也许有一些插件可以帮助解决这个问题?
I have large solution with about 40 separate javascript files, which are referenced to web page via special js-service. I want to use new IntelliSense features in VS2010, but it is very hard to add about 40 individual references like this:
/// <reference path="../../lib/jquery-1.3.2.js" />
to each js file in solution. Maybe there is some way to reference all files in folder? I've tried something like this:
/// <reference path="../../lib/*.*" />
but it is not working...
Thanks.
Update:
Maybe there are some add-in, which could help with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
添加对一个 js 文件的引用,最好是所有其他文件都依赖或使用的文件。然后在其他地方,仅包含对该 js 文件的引用。
即,file1.js 包含:
并且每个其他文件仅包含一个引用:
Visual Studio 2012 更新: 现在,您可以将全局引用放入
_references.js
文件中,以便intellisense 在其他 js 文件中自动可用。您还可以在“工具”>“工具”对话框中指定智能感知文件。 “选项”> “文本编辑器”> “JavaScript”> “智能感知”> “参考”。这篇博文中有更多详细信息:VS 2012 中的 JavaScript 智能感知,_references.js 文件
Add the references to one js file, ideally one that all the others rely on or use. Then everywhere else, include a reference to just that one js file.
ie, file1.js contains:
And every other file contains just one reference:
Update for Visual Studio 2012: You can now put global references in the
_references.js
file so that intellisense is available automatically in other js files. You can also specify intellisense files in the tools dialog under "Tools" > "Options" > "Text Editor" > "JavaScript" > "Intellisense" > "References".More detail in this blog post: JavaScript Intellisense in VS 2012, The _references.js File
您可以在解决方案资源管理器中选择其中的一堆并将它们拖到要使用 Intellisense 的 JS 文件的编辑器中。
它会根据您拖动的文件自动生成 /// 标签。
You can select a bunch of them in Solution Explorer and drag them onto the editor of the JS file you want to use Intellisense.
It will automatically generate the /// tags based on the file you dragged.
///... 行位于 js 文件中任何其他内容之前,这一点非常重要。甚至不能有一个空行。
那么一切都应该工作正常。
It is very important that the ///... lines come before ANYTHING ELSE in your js file. There must not even be a blank line.
Then all should work fine.
我使用的是VS2010,和user512395有同样的问题。
它曾经对我选择的答案有用。
我最近升级到了最新的 Resharper,它支持 Javascript 智能感知。
I am using VS2010, have the same problem as user512395.
It used to work for me with the chosen answer.
I have upgraded to latest Resharper that comes with Javascript intellisense support recently.
我的网站也遇到了同样的问题,但更新有所帮助。并且不要忘记空行,不应该有空行!
And I had the same problem with my website, but the update helped. And don't forget the blank lines, there shouldn't be any!