简体   繁体   English

Visual Studio 2012 JavaScript智能感知不起作用

[英]Visual Studio 2012 JavaScript Intellisense Not Working

I have Visual Studio 2012 installed on my laptop and desktop. 我在笔记本电脑和台式机上安装了Visual Studio 2012。 On my desktop PC, the JavaScript intellisense is not working. 在我的桌面PC上,JavaScript intellisense无效。 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". 对于它提出的任何方法(即使是标准的JavaScript调用),我收到消息,“Intellisense无法确定此表达式的准确完成列表”。

I've tried all of the suggestions from the other posts and tried everything I could find on Google. 我已经尝试了其他帖子中的所有建议,并尝试了我在Google上可以找到的所有内容。 Nothing has worked. 没有任何效果。 It isn't about not having JQuery Intellisense. 它不是没有JQuery Intellisense。 I don't get even basic JavaScript Intellisense. 我甚至没有得到基本的JavaScript Intellisense。

Edit: 编辑:

我发布了一张图片,但作为一个新用户,它不会让我。在此输入图像描述

The objects in the above images are simple strings, yet I don't get any help from the Intellisense. 上面图像中的对象是简单的字符串,但我没有从Intellisense得到任何帮助。

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 wrong was 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中复制所有jquery文件(main,minified,map和intellisense one)如果您在其他地方安装了Visual Studio 2012,则在Visual Studio中调整路径,在工具>选项>文本编辑器> Javascript>智能感知>参考>添加对jquery-1.9.1.js的引用(同样, 不是vsdoc或intellisense)文件 ,但主要的一个)如denas解决方案中所解释的 (但没有明确表示不指向vsdoc / intellisense文件)。

Hope this helps. 希望这可以帮助。

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 重新启动Windows并再次启动visual studio
  3. have another developer load your project and test it 有另一个开发人员加载您的项目并测试它
  4. create a bare bone project and test with all stock javascript references 创建一个裸骨项目并使用所有库存javascript引用进行测试
  5. reset IDE 重置IDE
  6. run VS in safe mode and test your project 安全模式运行VS并测试您的项目
  7. uninstall and reinstall vs 卸载并重新安装vs

I usually resolve most of the VS problems at step 3 or 4, and sometimes 5. 我通常在步骤3或4解决大多数VS问题,有时候解决5。

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 在此之后转到编辑>智能感知>刷新外部参考

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

In visual studio 2012, 在visual studio 2012中,
Using this solution https://github.com/jmbledsoe/angularjs-visualstudio-intellisense . 使用此解决方案https://github.com/jmbledsoe/angularjs-visualstudio-intellisense

Make sure put ng, ngCookies modules into required fields. 确保将ng,ngCookies模块放入必填字段。 For example: var module = angular.module("demo", ['ng','ngCookies']); 例如:var module = angular.module(“demo”,['ng','ngCookies']);

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM