简体   繁体   English

Bootstrap Intellisense缺少Visual Studio 2015

[英]Bootstrap Intellisense Missing Visual Studio 2015

I installed Visual Studio 2015 this week. 我本周安装了Visual Studio 2015。 However I discovered that I have no intellisense in my Razor Views. 但是我发现我的Razor Views中没有intellisense。

In Visual studio 2013 it worked fine. 在Visual Studio 2013中它运行良好。

My all my css files are under ~/Content/css/ ( *.min.css ), including bootstrap. 我的所有css文件都在~/Content/css/*.min.css )下,包括bootstrap。

Here is the bundle config: 这是捆绑配置:

bundles.Add(new StyleBundle("~/Content/smartadmin").IncludeDirectory("~/Content/css", "*.min.css"));

When I try to use some bootstrap css in my razor view, nothing pops up in the autocomplete box. 当我尝试在剃刀视图中使用一些引导程序css时,自动完成框中不会弹出任何内容。 There should be a purple icon next to the bootstrap classes right..? 右边的引导类旁边应该有一个紫色图标..? There are no icons and no css classes listed which is available under the bootstrap package. 没有列出图标,也没有列出引导程序包下可用的css类。

I did a sanity check and created a new MVC 5 application. 我做了一个完整性检查并创建了一个新的MVC 5应用程序。 This comes shipped with bootstrap. 这附带了bootstrap。 This works, all the intellisense is there. 这是有效的,所有的intellisense都在那里。

How do i fix this issue? 我该如何解决这个问题? Surely it must be a problem with my Solution? 当然,我的解决方案一定是问题吗? Does it not like the css files to be under a sub folder under content? 它不喜欢css文件在内容下的子文件夹下吗?

UPDATE: So i copied in the unminified versions of the files, then it got picked up. 更新:所以我复制了文件的未分类版本,然后它被拿起来了。 So anyone know the reason why VS does not pick up minified files for intellisense? 所以任何人都知道为什么VS没有为intellisense选择缩小的文件?

It seems like the solution is to add non-minified Files to your solution in order for intellisense to work. 似乎解决方案是将非缩小文件添加到您的解决方案中,以便智能感知工作。 I think it is due to Microsoft splitting out the minifier into a separate extension. 我认为这是由于微软将缩小器拆分为单独的扩展。

If your project type is an ASP.NET web application and you are using a 'Master page', the easy fix is to add a link to the css file in the master page. 如果您的项目类型是ASP.NET Web应用程序并且您使用的是“主页面”,则可以轻松解决方法是在母版页中添加指向css文件的链接。 For example, in the master page 'head' section I add: 例如,在主页'head'部分中我添加:

<link rel="stylesheet" href="Content/bootstrap.css" type="text/css" />

ASPX and other WebForm files using the legacy editor do not benefit from this implementation in VS 2013, but may adopt the new system in future releases. 使用旧版编辑器的ASPX和其他WebForm文件无法从VS 2013中的此实现中受益,但可能在将来的版本中采用新系统。

But you can still use this feature as follows: 但您仍然可以使用此功能,如下所示:

right click on the default.aspx file in the Solution Explorer open with select HTML Editor ok 右键点击default.aspx在Solution Explorer文件open with选择HTML Editor ok

If someone comes here and the accepted solution doesn't work. 如果有人来到这里并且接受的解决方案不起作用。

In my case I had to remove the database project (.sqlproj) from the solution for the Bootstrap css class intellisense to work. 在我的情况下,我必须从解决方案中删除数据库项目(.sqlproj)以使Bootstrap css类intellisense工作。

Remove the database project then restart Visual Studio. 删除数据库项目,然后重新启动Visual Studio。

And to be clear. 并且要清楚。 This is not a good solution as removing the database project is not what you want. 这不是一个好的解决方案,因为删除数据库项目不是您想要的。 So, hope someone finds a good solution to this weird bug. 所以,希望有人找到一个很好的解决这个奇怪的错误。

In my case, the intellisense not worrk because the path of bootstrap files was changed then files are not included in the project. 在我的情况下,intellisense不是worrk,因为bootstrap文件的路径被更改,然后文件不包含在项目中。

After adding files to the project works fine. 将文件添加到项目后工作正常。

I know... It is a simple solution. 我知道......这是一个简单的解决方案。 Sorry! 抱歉!

在此输入图像描述

I got it worked by ensuring all actual scripts are in place and in order. 我通过确保所有实际脚本到位并按顺序完成了它。

<script src="Scripts/jquery-3.2.1.js"></script>
<script src="Scripts/bootstrap.js"></script>
<script src="Scripts/angular.js"></script>

<link href="Content/bootstrap-theme.css" rel="stylesheet" />
<link href="Content/bootstrap.css" rel="stylesheet" />

After that I closed the visual studio solution and reopened it.Intelli-sense started working for bootstrap afterwards. 之后我关闭了visual studio解决方案并重新打开它.Intelli-sense随后开始为bootstrap工作。

What worked for me: Link to the full bootstrap css, close the view(s), rebuild the solution, open the view. 什么对我有用:链接到完整的bootstrap css,关闭视图,重建解决方案,打开视图。 Intellisense worked. Intellisense工作。 Change to the minified css, close the view, rebuild, open the view. 更改为缩小的css,关闭视图,重建,打开视图。 Intellisense still working. 智能感知仍然有效。

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

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