简体   繁体   English

jquery intellisense vs2010 mvc3

[英]jquery intellisense vs2010 mvc3

jQuery intellisense does not work for me unless I place: 除非我放置,否则jQuery intellisense对我不起作用:

<script src="../../Scripts/jquery-1.4.4-vsdoc.js" type="text/javascript"></script>

...in the page. ...在页面中。 I thought putting it in the _Layout.cshtml would be sufficient but it's not. 我认为把它放在_Layout.cshtml就足够了,但事实并非如此。

I have to do this on every page, partial etc. 我必须在每个页面,部分等上执行此操作。

Is this a bug or is there a better way to enable jQuery intellisense across all the pages and .js files? 这是一个错误还是有更好的方法在所有页面和.js文件中启用jQuery intellisense?

You can also use an if clause like: 您还可以使用if子句,如:

 @if (false) { 
    <script src="/Scripts/jquery-1.4.4-vsdoc.js" type="text/javascript"></script>
 }

If u need to add jQuery intellisense to a .js file, add this: 如果你需要将jQuery intellisense添加到.js文件中,请添加:

 /// <reference path="../../Scripts/jquery-1.5.1.min.js" />

If u need to add to a .cshtml file, try this: 如果你需要添加到.cshtml文件,试试这个:

 @* <reference path="../../Scripts/jquery-1.5.1.min.js" />*@

Visual Studio can read these refs even if they are in comments...which is kinda interesting. Visual Studio可以阅读这些引用,即使它们在评论中......这有点儿有趣。

Currenty you need to add a reference to a script in the file that you are editing for JavaScript IntelliSense to work in that fie. 当前,您需要在正在编辑的文件中添加对脚本的引用,以便JavaScript IntelliSense在该文件中工作。 This is because layouts in Razor are set imperatively during the page's execution and not declaratively. 这是因为Razor中的布局在页面执行期间必须设置,而不是以声明方式设置。

Note that you should be able to put HTML comment blocks around your script references so that multiple references to the same script file will be ignored when rendered in the browser. 请注意,您应该能够在脚本引用周围放置HTML注释块,以便在浏览器中呈现时,将忽略对同一脚本文件的多个引用。

 @if (false) { 
    <script src="/Scripts/jquery-1.4.4-vsdoc.js" type="text/javascript"></script>
 }

works but i feel its awful. 工作,但我感觉很糟糕。 surely there MUST be a Nuget for this!? 肯定有一个Nuget为此!? VS2010 here VS2010在这里

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

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