jQuery Intellisense:vsdoc 的通用参考文件 (stdafx)
昨天我将项目中的 jQuery 移至 Microsoft 的 CDN,所以 jQuery 智能感知终于回来了。耶!但是,我显然需要在所有 .js 文件中包含以下内容:
//These references should enable intellisense within this file
///<reference path="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.4.js" />
///<reference path="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/jquery-ui.min.js" />
我希望有一个包含上述引用的单个 js 文件,这样我在所有 js 文件中就有一个单一的、不变的引用,如下所示
//These references should enable intellisense within this file
///<reference path="/shared/js/stdafx.js" />
: stdafx.js 将是包含 jQuery 引用的文件。那么我就只有一个地方来更新版本或添加额外的引用。我快速尝试了一下,但似乎没有效果。任何人都可以找到一种方法来实现这一点吗?
I moved the jQuery in my project over to Microsoft's CDN yesterday so finally have jQuery intellisense back. Yay! However, I apparently need to include the following in all my .js files:
//These references should enable intellisense within this file
///<reference path="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.4.js" />
///<reference path="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/jquery-ui.min.js" />
I would prefer to have a single js file which contains the above references such that I have a single, unchanging reference in all my js files like so:
//These references should enable intellisense within this file
///<reference path="/shared/js/stdafx.js" />
The idea is that stdafx.js would be the file containing the jQuery references. Then I have only one place to update the versions or add additional references. I gave it a quick go, but it didn't seem to work. Can anyone figure out a way to make this happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上,上面的通用参考最终确实起作用了。我没有意识到 VS 在 js 智能感知方面有多么古怪。有趣的是,它在编译项目后就开始了。
我确实尝试过使用 Ctrl-Shift-J 来刷新 JavaScript。它需要几秒钟的时间才能启动,所以给它一个机会。我读到的另一个技巧是将 common.js 文件拖到我想要添加公共引用的 .js 文件的编辑器中。这个健全性检查确保我有正确的路径(确实如此)。它添加了相对路径 (../shared/stdafx.js),但我能够使用绝对路径 (/shared/js/stdafx.js),这意味着我可以修改新 js 文件的 VS .js 模板。
所以我建议任何遇到这个问题的人坚持下去,刷新 JavaScript,编译,甚至关闭并重新打开 VS,因为它最终有望为你带来帮助。
Actually the above common reference did work in the end. I didn't realize how quirky VS was in regards to js intellisense. Funny enough it kicked in after compiling the project.
I did try Ctrl-Shift-J which refreshes the JavaScript as well. It takes a few seconds for it to kick in so give it a chance. Another tip I read was dragging the common.js file into the editor of the .js file I wanted to add the common reference to. This sanity check ensured I had the correct path (it did). It added a relative path (../shared/stdafx.js) but I was able to use an absolute path (/shared/js/stdafx.js) which means I can modify the VS .js template for new js files.
So I would suggest anyone who comes across this question to persevere, refresh the JavaScript, compile, even close and reopen VS as it will hopefully kick in for you eventually.
对于任何仍然希望在 .js 文件中使用 jQuery intellisense 的人(为什么不呢),您需要“引用”正确的 jQuery VSDOC 文件,该文件是 MS 为 Visual Studio intellisense 创建的:
///
要测试它,请键入:
$(
您应该看到带有 PARAMETERS 的完整智能感知以及成员。如果您只看到单个成员列表,则它不起作用。
For anyone still wanting jQuery intellisense in their .js files (and why wouldn't you) you need to 'reference' the correct jQuery VSDOC file, that MS created for Visual Studio intellisense:
///<reference path="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2-vsdoc.js" />
To test it, type:
$(
You should see full intellisense with PARAMETERS, as well as members. If you only see a single list of members, it's not working.