[英]VS 2010 Javascript Intellisense not working
I am writing javascript code which uses jQuery and unfortunately when I create a .js file with the following: 我正在编写使用jQuery的javascript代码,不幸的是,当我使用以下代码创建.js文件时:
/// <reference path="jquery-1.4.2.js" />
(function($) {
// use $ here
})(jQuery);
I don't get any intellisense for $. 我没有$的任何智能感知。 However I still get intellisense if I use "jQuery".
但是,如果我使用“ jQuery”,我仍然会得到智能感知。 This seems like an oversight to me because Visual Studio should recognise that I am creating an anonymous function and immediately executing it with jQuery passed in.
这对我来说似乎是一个疏忽,因为Visual Studio应该认识到我正在创建一个匿名函数并立即使用传入的jQuery执行它。
Does anyone have a workaround / fix? 有人有解决方法/修复方法吗?
Unfortunately there's no work-around I'm aware of, except doing this: 不幸的是,除了这样做,我没有其他解决方法:
(function($) {
$ = jQuery; //remove or comment this before it goes to the minifier
// use $ here
})(jQuery);
I do this when strip that out $ = jQuery;
我在将
$ = jQuery;
除去时执行此操作$ = jQuery;
as part of the build (if I need intellisense that badly in the file). 作为构建的一部分(如果我在文件中非常需要智能感知)。 I'm hoping the Visual Studio team fixes this in SP1, but I also haven't seen any news saying they have yet.
我希望Visual Studio团队在SP1中修复此问题,但我还没有看到任何消息表明它们尚未发布。 Check out Michaud's blog here with a few quotes from the VS team on the issue .
在此处查看Michaud的博客,并附上VS团队对此问题的一些引用 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.