简体   繁体   English

通过 CDN 进行引导的 Visual Studio 智能感知

[英]Visual Studio intellisense for Bootstrap via CDN

I've installed Bootstrap via the Microsoft CDN like:我已经通过 Microsoft CDN 安装了 Bootstrap,例如:

<head>
    ...
   <link href="//ajax.aspnetcdn.com/ajax/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
   <link href="//ajax.aspnetcdn.com/ajax/bootstrap/3.1.1/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css" />
</head>

and

<body>
    ...
    <script src="//ajax.aspnetcdn.com/ajax/bootstrap/3.1.1/bootstrap.min.js"></script>
</body>

Everything is working fine with Bootstrap, however, Visual Studio isn't giving me any kind of intellisense for the classes. Bootstrap 一切正常,但是,Visual Studio 并没有为我提供任何类型的智能感知。

For example, typing例如,键入

<div class="(intellisense should open here)

nothing comes up.什么都没有出现。

Is there any way to get intellisense from the CDN?有没有办法从 CDN 获得智能感知?

If you are working with ASP.NET Core project do as follows.如果您正在使用ASP.NET Core项目,请执行以下操作。 VS only reference files inside the wwwroot folder. VS 仅引用wwwroot文件夹内的文件。 You need to open the .您需要打开 . csproj file and add the following code segment. csproj文件并添加以下代码段。

<ItemGroup>
  <None Include="node_modules/**" />
</ItemGroup>

After that VS will picking up intellicen from node_modules.之后 VS 将从 node_modules 中获取智能。

You can add CDN references to intelliSence for javascript , however, css is not supported .您可以为javascript添加对 IntelliSence 的 CDN 引用,但是不支持css

Visual Studio 2013 选项

You can add the file to your project and it will work, you dont need to add a ref to html, just to project and it should resolve your issue.您可以将文件添加到您的项目中,它会起作用,您不需要将 ref 添加到 html,只需添加到项目中,它应该可以解决您的问题。

You need to install bootstrap through the NuGet Packages.您需要通过 NuGet 包安装引导程序。 Intellisense will start working after that. Intellisense 将在此之后开始工作。

我刚刚安装了引导 nuget

Open Visual Studio打开Visual Studio

Go in Extensions and Updates and then click on Online Tab.进入扩展和更新,然后单击在线选项卡。

In Search type Bootstrap .在搜索类型Bootstrap

Install following Packs to enable intellisense.安装以下包以启用智能感知。 Ensure that you have dragged bootstrap.css (or bootstrap.min.css and js file) before trying to insert snippet.在尝试插入片段之前,请确保您已拖动 bootstrap.css(或 bootstrap.min.css 和 js 文件)。

  • Bootstrap Bundle引导包
  • Bootstrap Snippet Pack引导片段包

在此处输入图像描述

TOOLS->Options->Text Editor->the specific language ->IntelliSense工具->选项->文本编辑器->特定语言->智能感知

That should get the intellisense back up and running, worked for me before (think this is what you are looking for)这应该让智能感知重新启动并运行,以前为我工作过(认为这就是你要找的东西)

I know this way is not exactly CDN, but it worked for me and you can still keep your packages up-to-date我知道这种方式不完全是 CDN,但它对我有用,你仍然可以让你的包保持最新

You can reference Bootstrap using Bower.您可以使用 Bower 引用 Bootstrap。

On the package.json you would have:在 package.json 上,您将拥有:

{
  "version": "1.0.0",
  "name": "TaskAngularJSApp",
  "private": true,
  "devDependencies": {
    "grunt": "0.4.5",
    "grunt-contrib-uglify": "0.7.0",
    "grunt-contrib-watch": "0.6.1",
    "bower": "1.7.3"
  }
}

Then you have bower.json file like:然后你有 bower.json 文件,如:

{
    "name": "ASP.NET",
    "private": true,
    "dependencies": {
        "bootstrap": "*"
    }
}

Then on your html you would reference bootstrap like然后在你的 html 上你会引用 bootstrap 之类的

    <link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap.min.css" />
    <script src="/lib/bootstrap/dist/js/bootstrap.min.js"></script>

I got help from: using grunt bower gulp npm with visual studio 2015 for a asp-net-4-5-project我得到了帮助: 将 grunt bower gulp npm 与 Visual Studio 2015 一起用于 asp-net-4-5-project

and

Released Today: Visual Studio 2015, ASP.NET 4.6, ASP.NET 5 & EF 7 Previews - On the "HTML Editor Updates" section 今日发布:Visual Studio 2015、ASP.NET 4.6、ASP.NET 5 和 EF 7 预览版- 在“HTML 编辑器更新”部分

Content文件夹中复制bootstrap.css

在 HTML 设置中包含旧的 Razor 编辑器对我有帮助 - https://github.com/dotnet/razor-tooling/issues/5669

Go to TOOLS->Options->Text Editor->HTML->Advanced->Razor-> Select True转到工具-> 选项-> 文本编辑器-> HTML-> 高级-> 剃刀-> 选择 True

在此处输入图像描述

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

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