VS 2010 Javascript Intellisense无法正常工作

时间:2010-11-05 11:10:12

标签: javascript jquery visual-studio-2010 intellisense javascript-intellisense

我正在编写使用jQuery的javascript代码,不幸的是,当我使用以下内容创建.js文件时:

/// <reference path="jquery-1.4.2.js" />
(function($) {

  // use $ here

})(jQuery);

我没有得到任何intellisense $。但是,如果我使用“jQuery”,我仍然可以获得intellisense。这似乎是对我的疏忽,因为Visual Studio应该认识到我正在创建一个匿名函数并立即执行它并传入jQuery。

有没有人有解决方法/修复方法?

1 个答案:

答案 0 :(得分:1)

不幸的是,我没有意识到这一点,除了这样做:

(function($) {
  $ = jQuery; //remove or comment this before it goes to the minifier
  // use $ here

})(jQuery);

当我将$ = jQuery;作为构建的一部分去掉时(如果我需要在文件中严重的智能感知),我会这样做。我希望Visual Studio团队在SP1中修复此问题,但我还没有看到任何消息说他们还没有。 Check out Michaud's blog here with a few quotes from the VS team on the issue