[英]How to reference multiple files for javascript IntelliSense in VS2010
I have large solution with about 40 separate javascript files, which are referenced to web page via special js-service.我有大约 40 个单独的 javascript 文件的大型解决方案,这些文件通过特殊的 js 服务引用到网页。 I want to use new IntelliSense features in VS2010, but it is very hard to add about 40 individual references like this:
我想在 VS2010 中使用新的 IntelliSense 功能,但很难像这样添加大约 40 个单独的引用:
/// <reference path="../../lib/jquery-1.3.2.js" />
to each js file in solution.解决方案中的每个 js 文件。 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?更新:也许有一些插件可以帮助解决这个问题?
Add the references to one js file, ideally one that all the others rely on or use.添加对一个 js 文件的引用,最好是所有其他文件都依赖或使用的文件。 Then everywhere else, include a reference to just that one js file.
然后在其他任何地方,只包含对那个 js 文件的引用。
ie, file1.js contains:即,file1.js 包含:
/// <reference path="file2.js" />
/// <reference path="file3.js" />
...
/// <reference path="file40.js" />
And every other file contains just one reference:每个其他文件只包含一个参考:
/// <reference path="file1.js" />
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. Visual Studio 2012 更新:您现在可以将全局引用放在
_references.js
文件中,以便智能感知在其他 js 文件中自动可用。 You can also specify intellisense files in the tools dialog under "Tools" > "Options" > "Text Editor" > "JavaScript" > "Intellisense" > "References".您还可以在“工具”>“选项”>“文本编辑器”>“JavaScript”>“智能感知”>“参考”下的工具对话框中指定智能感知文件。
More detail in this blog post: JavaScript Intellisense in VS 2012, The _references.js File此博客文章中的更多详细信息: VS 2012 中的 JavaScript Intellisense,_references.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.您可以在 Solution Explorer 中选择其中的一组并将它们拖到您要使用 Intellisense 的 JS 文件的编辑器中。
It will automatically generate the /// tags based on the file you dragged.它会根据您拖动的文件自动生成 /// 标签。
It is very important that the ///... lines come before ANYTHING ELSE in your js file.在您的 js 文件中,///... 行位于其他任何内容之前,这一点非常重要。 There must not even be a blank line.
甚至不能有空行。
Then all should work fine.然后一切都应该正常工作。
I am using VS2010, have the same problem as user512395.我正在使用 VS2010,与 user512395 有同样的问题。 It used to work for me with the chosen answer.
它曾经为我选择的答案工作。 I have upgraded to latest Resharper that comes with Javascript intellisense support recently.
我最近升级到最新的 Resharper,它带有 Javascript intellisense 支持。
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!
并且不要忘记空行,不应该有空行!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.