如何在VS2010中引用javascript IntelliSense的多个文件 [英] How to reference multiple files for javascript IntelliSense in VS2010
问题描述
我有大约40个单独的javascript文件的大型解决方案,这些文件通过特殊的js-service引用到网页。我想在VS2010中使用新的IntelliSense功能,但很难添加大约40个单独的引用,如下所示:
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" />
到解决方案中的每个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?
推荐答案
将引用添加到一个js文件中,理想情况下是所有其他js文件依赖或使用的文件。然后在其他地方,包括对一个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.
即,file1.js包含:
ie, file1.js contains:
/// <reference path="file2.js" />
/// <reference path="file3.js" />
...
/// <reference path="file40.js" />
并且每个其他文件只包含一个参考:
And every other file contains just one reference:
/// <reference path="file1.js" />
Visual Studio 2012更新:现在可以将全局引用放入 _references.js
文件,以便智能感知在其他js文件中自动可用。您还可以在工具>选项>文本编辑器>JavaScript>智能感知>参考下的工具对话框中指定智能感知文件。
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".
此博客文章中的更多细节: VS 2012中的JavaScript Intellisense,_references.js文件
More detail in this blog post: JavaScript Intellisense in VS 2012, The _references.js File
这篇关于如何在VS2010中引用javascript IntelliSense的多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!