Visual Studio intellisense for Bootstrap via CDN

2019-02-06 04:58发布

问题:

I've installed Bootstrap via the Microsoft CDN like:

<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.

For example, typing

<div class="(intellisense should open here)

nothing comes up.

Is there any way to get intellisense from the CDN?

回答1:

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

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.



回答2:

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



回答3:

If you are working with ASP.NET Core project do as follows. VS only reference files inside the wwwroot folder. You need to open the .csproj file and add the following code segment.

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

After that VS will picking up intellicen from node_modules.



回答4:

Open Visual Studio

Go in Extensions and Updates and then click on Online Tab.

In Search type 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 Bundle
  • Bootstrap Snippet Pack



回答5:

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)



回答6:

I know this way is not exactly CDN, but it worked for me and you can still keep your packages up-to-date

You can reference Bootstrap using Bower.

On the package.json you would have:

{
  "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:

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

Then on your html you would reference bootstrap like

    <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

and

Released Today: Visual Studio 2015, ASP.NET 4.6, ASP.NET 5 & EF 7 Previews - On the "HTML Editor Updates" section



回答7:

In the Content folder copy bootstrap.css.



回答8:

I just installed the bootstrap nuget