Visual Studio 2012 JavaScript Intellisense 不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13204428/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 18:04:02  来源:igfitidea点击:

Visual Studio 2012 JavaScript Intellisense Not Working

javascriptvisual-studio-2012intellisense

提问by EL MOJO

I have Visual Studio 2012 installed on my laptop and desktop. On my desktop PC, the JavaScript intellisense is not working. For any method it pulls up (even standard JavaScript calls) I receive the message, "Intellisense was unable to determine an accurate completion list for this expression".

我的笔记本电脑和台式机上都安装了 Visual Studio 2012。在我的台式 PC 上,JavaScript 智能感知不起作用。对于它调用的任何方法(甚至是标准的 JavaScript 调用),我都会收到消息“Intellisense 无法确定此表达式的准确完成列表”。

I've tried all of the suggestions from the other posts and tried everything I could find on Google. Nothing has worked. It isn't about not having JQuery Intellisense. I don't get even basic JavaScript Intellisense.

我已经尝试了其他帖子中的所有建议,并尝试了我在 Google 上能找到的所有内容。没有任何效果。这与没有 JQuery Intellisense 无关。我什至不了解基本的 JavaScript Intellisense。

Edit:

编辑:

I'd post an image but as a new user it won't let me.enter image description here

I'd post an image but as a new user it won't let me.enter image description here

The objects in the above images are simple strings, yet I don't get any help from the Intellisense.

上图中的对象是简单的字符串,但我没有从 Intellisense 获得任何帮助。

回答by firepol

I had the same problem: in Visual Studio 2010 I was used to add a reference in my javascript files, at the top, like this:

我遇到了同样的问题:在 Visual Studio 2010 中,我习惯于在我的 javascript 文件中添加一个引用,在顶部,如下所示:

/// <reference path="/scripts/jquery-1.7.1-vsdoc.js" />

With the new Visual Studio 2012 this was not working anymore, I looked around and found the solution to put the reference in /scripts/_references.js I did so, not working.

使用新的 Visual Studio 2012,这不再起作用,我环顾四周,找到了将引用放在 /scripts/_references.js 中的解决方案,我这样做了,但不起作用。

What I was doing wrongwas that I was referencing the vsdoc.js file, or at the moment of writing, nuget downloaded jquery 1.9.1 package, reference to jquery-1.9.1.intellisense.js which is WRONG.

做错的是我引用了 vsdoc.js 文件,或者在撰写本文时,nuget 下载了 jquery 1.9.1 包,引用了错误的 jquery-1.9.1.intellisense.js。

The correct reference(if using the /scripts/_references.js file) is:

正确的引用(如果使用的是/scripts/_references.js文件):

/// <reference path="/scripts/jquery-1.9.1.js" />

(NOT the .intellisense.js or the -vsdoc.js file).

(不是 .intellisense.js 或 -vsdoc.js 文件)

For the global solution to work on all your projects:copy all the jquery files (main, minified, map, and intellisense one, to be sure) in C:\Program Files (x86)\Microsoft Visual Studio 11.0\JavaScript\References (adapt the path if you installed Visual Studio 2012 somewhere else) and in Visual Studio, under Tools > Options > Text Editor > Javascript > Intellisense > References > Add a reference to jquery-1.9.1.js (again, NOT the vsdoc or intellisense file, but the main one) as explained in the solution by denas(but it was not clearly said not to point the vsdoc/intellisense file).

对于适用于所有项目的全局解决方案:复制 C:\Program Files (x86)\Microsoft Visual Studio 11.0\JavaScript\References (如果您在其他地方安装了 Visual Studio 2012,请调整路径)并在 Visual Studio 中,在工具 > 选项 > 文本编辑器 > Javascript > Intellisense > 参考 > 添加对 jquery-1.9.1.js 的引用(同样,不是 vsdoc 或 Intellisense file,但主要的)如denas解决方案中所解释的(但没有明确说明不指向 vsdoc/intellisense 文件)。

Hope this helps.

希望这可以帮助。

回答by Ray Cheng

Many things can cause problems like this, but I usually follow these steps to troubleshoot it.

很多事情都会导致这样的问题,但我通常会按照这些步骤来解决它。

  1. close visual studio and restart
  2. reboot windows and start visual studio again
  3. have another developer load your project and test it
  4. create a bare bone project and test with all stock javascript references
  5. reset IDE
  6. run VS in safe modeand test your project
  7. uninstall and reinstall vs
  1. 关闭视觉工作室并重新启动
  2. 重新启动 Windows 并再次启动 Visual Studio
  3. 让另一个开发人员加载您的项目并对其进行测试
  4. 创建一个裸骨项目并使用所有股票 javascript 参考进行测试
  5. 重置IDE
  6. 安全模式下运行 VS并测试您的项目
  7. 卸载并重新安装 vs

I usually resolve most of the VS problems at step 3 or 4, and sometimes 5.

我通常在第 3 步或第 4 步(有时是第 5 步)中解决大部分 VS 问题。

回答by Warren

If you've installed VS on anything other than the C Drive this will happen.

如果您在 C 驱动器以外的任何设备上安装了 VS,就会发生这种情况。

In Visual Studio, under Tools > Options > Text Editor > Javascript > Intellisense > References

在 Visual Studio 中,在“工具”>“选项”>“文本编辑器”>“Javascript”>“智能感知”>“参考”下

Add references to the same .js files that exist in the list but pointing to the new path where you have VS installed

添加对列表中存在的相同 .js 文件的引用,但指向安装 VS 的新路径

eg - G:\Program Files\Microsoft Visual Studio 11.0\JavaScript\References.libhelp.js

例如 - G:\Program Files\Microsoft Visual Studio 11.0\JavaScript\References.libhelp.js

There are 5 of them

其中有5个

After this go to Edit> Intellisense > Refresh external references

在这之后去编辑>智能感知>刷新外部参考

回答by starbugs

In visual studio 2012,
Using this solution https://github.com/jmbledsoe/angularjs-visualstudio-intellisense.

在 Visual Studio 2012 中,
使用此解决方案https://github.com/jmbledsoe/angularjs-visualstudio-intellisense

Make sure put ng, ngCookies modules into required fields. For example: var module = angular.module("demo", ['ng','ngCookies']);

确保将 ng、ngCookies 模块放入必填字段。例如: var module = angular.module("demo", ['ng','ngCookies']);

回答by vineel

An excellent article by Mads Kristensen helped me fix the JavaScript Intellisense issue.

Mads Kristensen 的一篇优秀文章帮助我解决了 JavaScript Intellisense 问题。

Triple-slash references look like this and can be added to the top of any .js file or in /scripts/_references.js file

三斜杠引用看起来像这样,可以添加到任何 .js 文件的顶部或 /scripts/_references.js 文件中

/// <reference path="../app/respond.js" />

REF: http://madskristensen.net/post/the-story-behind-_referencesjs

参考资料:http: //madskristensen.net/post/the-story-behind-_referencesjs

回答by Steve Mannina

I fixed the same problem by right-clicking the file in Solution Explorer and choosing Open With and then choosing Web Form Editor if you're editing a Web form or Source Code (Text) Editor if you're editing a JavaScript file.

我通过在解决方案资源管理器中右键单击文件并选择打开方式,然后在编辑 Web 表单时选择 Web 表单编辑器或在编辑 JavaScript 文件时选择源代码(文本)编辑器来解决相同的问题。