简体   繁体   English

jQuery UI 打破了 Visual Studio 2015 Intellisense

[英]jQuery UI breaks Visual Studio 2015 Intellisense

I am finding a frustrating issue with JavaScript intellisense where if I include jQuery UI in my _references.js file I lose all JavaScript intellisense.我发现 JavaScript 智能感知存在一个令人沮丧的问题,如果我在_references.js文件中包含 jQuery UI,我将丢失所有 JavaScript 智能感知。 Does anyone know if there is a way to fix this problem beyond removing jQuery UI from the _references.js ?有谁知道除了从_references.js删除 jQuery UI 之外,是否还有办法解决这个问题?

Update更新

  • I do know that more files in the _references.js file will cause it to slow down, that makes sense.我知道_references.js文件中的更多文件会导致它变慢,这是有道理的。 However, I have projects at work which include far more files (on the order of 600) with no typesense issues, and my project has 20. So it's not a matter of "too many files."但是,我有一些项目在工作,其中包含更多文件(大约 600 个)而没有类型问题,而我的项目有 20 个。所以这不是“文件太多”的问题。
  • I pulled my project from Git to a separate computer (therefore separate installation of VS15) and tried including the jQuery UI file and this still caused the loss of intellisense in my project.我将我的项目从 Git 拉到一台单独的计算机(因此单独安装了 VS15)并尝试包含 jQuery UI 文件,但这仍然导致我的项目中的智能感知丢失。
    • It can't be an installation issue since other work projects include jQuery UI and there are no intellisense issues这不可能是安装问题,因为其他工作项目包括 jQuery UI 并且没有智能感知问题
  • I do realize that I can manually manage _references.js to accomplish the task, but I would like to fix it altogether since I hate needing to add information twice (create the JS file and then update _refernces.js ).我确实意识到我可以手动管理_references.js来完成任务,但我想完全修复它,因为我讨厌需要添加两次信息(创建 JS 文件然后更新_refernces.js )。

With this new information, I'm thinking it must be some type of deeper issue in my project's setup that is causing the issue as opposed to an installation based issue or jQuery UI specific issue.有了这些新信息,我认为它一定是我的项目设置中某种更深层次的问题导致了问题,而不是基于安装的问题或 jQuery UI 特定问题。 Does anyone have any ideas on what settings in a .sln or .csproj file might cause JS Intellisense issues?有没有人对 .sln 或 .csproj 文件中的哪些设置可能导致 JS Intellisense 问题有任何想法?

For those who experience this issue, I found that using jQuery 3.x was causing instellisense to break when jQuery UI was included in _references.js .对于遇到此问题的人,我发现当_references.js中包含 jQuery UI 时,使用 jQuery 3.x 会导致 instellisense 中断。 My solution was using NuGet to change back to version 2.2.4 and everything started to work fine again.我的解决方案是使用 NuGet 改回 2.2.4 版,一切又开始正常工作。

I've got the same problem.我有同样的问题。 I tried quite a few things but the only thing I could get to consistently work was to disable the auto sync feature and remove the jquery UI reference.我尝试了很多东西,但我唯一能持续工作的是禁用自动同步功能并删除 jquery UI 引用。 Intellisense also seems to slow down a good bit with more and more libraries, almost to the point it looks like it is not working.随着越来越多的库,Intellisense 似乎也放慢了很多,几乎到了它看起来不起作用的地步。 I finally just got to the point where I only include my own scripts and jquery for helpful reminders on syntax.我终于到了我只包含我自己的脚本和 jquery 以提供有关语法的有用提醒的地步。 Unfortunately this means I have to manually keep the _references.js file up to date but it's definitely better than it not working at all.不幸的是,这意味着我必须手动使 _references.js 文件保持最新,但这绝对比根本不工作要好。

You can also limit your global references in the _references file and drag the script files that you want intellisense for to each view if you are like me where you have a script file for each view.如果您像我一样,每个视图都有一个脚本文件,您还可以在 _references 文件中限制您的全局引用,并将您想要智能感知的脚本文件拖到每个视图中。 That way you don't get intellisense for scripts that aren't even rendered to the view.这样你就不会得到甚至没有渲染到视图的脚本的智能感知。

not sure if this will help you but have you added this to the top of your .js file?不确定这是否对您有帮助,但您是否将其添加到 .js 文件的顶部?

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

that's the path that's made if you you've used NuGet to install jquery for your solution.如果您使用 NuGet 为您的解决方案安装 jquery,那么这就是创建的路径。 If you've located your jquery file and intellisense file elsewhere use that path instead (I do believe they need to be in the same folder).如果您在其他地方找到了 jquery 文件和智能感知文件,请改用该路径(我相信它们需要位于同一文件夹中)。

I found a better solution!我找到了更好的解决方案! Simple rename jquery-ui-1.12.1.js (or similar) to _jquery-ui-1.12.1.js .简单地将jquery-ui-1.12.1.js (或类似名称)重命名为_jquery-ui-1.12.1.js This will cause it to appear at the top BEFORE the conflicting jQuery 3 references in the _references.js file that cause intellisense to not work.这将导致它出现在_references.js文件中冲突的 jQuery 3 引用之前,导致智能感知不起作用。 Be sure to also update any script tag or BundleConfig.cs references you have to include the new underscore character prefix!请务必同时更新您必须包含新下划线字符前缀的任何脚本标记或BundleConfig.cs引用!

Solution:解决方法:

In your _references.js file:在您的_references.js文件中:

  1. Move the JQuery-UI reference above the main JQuery reference将 JQuery-UI 参考移动到主 JQuery 参考之上
  2. Disable auto-sync禁用自动同步

such as:例如:

/// <autosync enabled="false" />
/// <reference path="jquery-ui-1.12.1.js" />
/// <reference path="jquery-3.3.1.js" />

Drawbacks:缺点:

  • You will have to repeat step 1 every time you Update JavaScript References (right-click on _references.js to update references in Visual Studio).每次更新 JavaScript 引用时都必须重复步骤 1(右键单击_references.js以更新 Visual Studio 中的引用)。

在此处输入图片说明

Always install jQuery first any version you like and then install JQuery-ui.始终先安装 jQuery 任何您喜欢的版本,然后安装 JQuery-ui。 If you want to upgrade or degrade version of JQuery, you have to uninstall and again install JQuery-ui every time you do changes.如果要升级或降级 JQuery 版本,每次更改时都必须卸载并重新安装 JQuery-ui。 First Jquery-3.6.0.js then Jquery-ui-1.12.1.js and you have to reinstall jquery-ui every time you make changes in jquery.首先是 Jquery-3.6.0.js,然后是 Jquery-ui-1.12.1.js,每次在 jquery 中进行更改时都必须重新安装 jquery-ui。

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

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