简体   繁体   English

VS 2010 Javascript Intellisense无法正常工作

[英]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.

相关问题 VS JavaScript IntelliSense无法正常工作 - VS JavaScript IntelliSense not working as expected JavaScript 的 VS Code Intellisense 不起作用? - VS Code Intellisense for JavaScript is not working? Visual Studio 2010 Javascript Intellisense无法正常工作 - Visual Studio 2010 Javascript Intellisense not working properly 可以在VS 2010中获取自定义javascript文件以进行智能感知吗? - Possible to get custom javascript files to have intellisense in VS 2010? VS2010中的JavaScript Intellisense极其缓慢且内存耗尽 - JavaScript Intellisense in VS2010 extremely slow and memory hungry 如何在 VS2010 中为 javascript IntelliSense 引用多个文件 - How to reference multiple files for javascript IntelliSense in VS2010 VS2013 Javascript intellisense不适用于一切 - VS2013 Javascript intellisense not working for everything VS Code 中 Javascript 的 Intellisense 自动完成功能不起作用 - Intellisense autocompletion for Javascript in VS Code not working 带有参数的VS JavaScript智能感知 - VS JavaScript intellisense with paramaters 如果我正在编辑打字稿,则javascript的VS Code intellisense无法正常工作 - VS Code intellisense for javascript not working if I am editing typescript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM