VS 2010 Javascript Intellisense 不工作

发布于 2024-09-30 14:37:47 字数 321 浏览 0 评论 0原文

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

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

  // use $ here

})(jQuery);

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

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

I am writing javascript code which uses jQuery and unfortunately when I create a .js file with the following:

/// <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". 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.

Does anyone have a workaround / fix?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一城柳絮吹成雪 2024-10-07 14:37:47

不幸的是,除了这样做之外,我不知道有什么解决方法:

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

})(jQuery);

我在将其作为构建的一部分剥离 $ = jQuery; 时执行此操作(如果我在文件中非常需要智能感知) 。我希望 Visual Studio 团队在 SP1 中修复这个问题,但我还没有看到任何消息说他们已经修复了。 查看 Michaud 的博客,其中引用了 VS 团队关于问题

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; 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. Check out Michaud's blog here with a few quotes from the VS team on the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文