CSS 通过 CDN 用于 Bootstrap 的 Visual Studio 智能感知

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24296472/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:35:46  来源:igfitidea点击:

Visual Studio intellisense for Bootstrap via CDN

cssvisual-studio-2012twitter-bootstrap-3intellisensecdn

提问by Scottie

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 获取智能感知?

采纳答案by Samuel Pinto

You can add CDN references to intelliSence for javascript, however, cssis not supported.

您可以为javascript添加对 intelliSence 的 CDN 引用,但是,不支持css

Visual Studio 2013 options

Visual Studio 2013 选项

You can add the file to your projectand it will work, you dont need to add a ref to html, just to project and it should resolve your issue.

您可以将文件添加到您的项目中,它会起作用,您不需要向 html 添加 ref,只需添加到项目即可解决您的问题。

回答by shana

If you are working with ASP.NET Coreproject do as follows. VS only reference files inside the wwwrootfolder. You need to open the .csprojfile and add the following code segment.

如果您正在使用ASP.NET Core项目,请执行以下操作。VS 仅引用wwwroot文件夹内的文件。您需要打开 . csproj文件并添加以下代码段。

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

After that VS will picking up intellicen from node_modules.

之后 VS 将从 node_modules 中获取智能。

回答by mjdev

You need to install bootstrap through the NuGet Packages. Intellisense will start working after that.

您需要通过 NuGet 包安装引导程序。Intellisense 将在此之后开始工作。

回答by vibs2006

Open Visual Studio

打开Visual Studio

Go in Extensions and Updatesand then click on OnlineTab.

进入扩展和更新,然后单击在线选项卡。

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
  • 引导程序包
  • Bootstrap 代码段包

enter image description here

enter image description here

回答by Mocas

I just installed the bootstrap nuget

我刚刚安装了引导程序 nuget

回答by Mocas

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)

这应该让智能感知重新启动并运行,之前为我工作(认为这就是你正在寻找的)

回答by Divi perdomo

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 上,您将引用引导程序,例如

    <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 编辑器更新”部分

回答by Tonatio

In the Contentfolder copy bootstrap.css.

Content文件夹中复制bootstrap.css