简体   繁体   English

如何在 Visual Studio 2019 上使用 Bootstrap 5 和 Sass

[英]How to use Bootstrap 5 & Sass on Visual Studio 2019

I have installed Install-Package bootstrap.sass in ASP .net core 3.1.我已经在 ASP .net 核心 3.1 中安装了Install-Package bootstrap.sass

It has installed bootstrap.js and scss folder.它已经安装了bootstrap.jsscss文件夹。 But how to compile the bootrap.scss and use that in the _Layout?但是如何编译 bootrap.scss 并在 _Layout 中使用它呢?

I tried to import the bootstrap from scss but it gives me the error as:我试图从 scss 导入引导程序,但它给了我错误: 在此处输入图像描述

The NuGet has installed the following file: NuGet 已安装以下文件:

在此处输入图像描述

You can follow the steps below to set up Bootstrap 5 SASS using ASPNET Core.您可以按照以下步骤使用 ASPNET Core设置 Bootstrap 5 SASS

  1. Delete the /wwwroot/lib/bootstrap folder :删除/wwwroot/lib/bootstrap 文件夹
    • If your application already contains Bootstrap, you will need to delete these files.如果您的应用程序已经包含 Bootstrap,则需要删除这些文件。
  2. Choose the scss folder and click install:选择scss文件夹并点击安装:
    • You can right-click wwwroot and select Add->Client-Side Library .您可以右键单击wwwroot和 select Add->Client-Side Library Select unpkg provider, " bootstrap@5.0.1 " library. Select unpkg提供程序,“ bootstrap@5.0.1 ”库。
    • [ [在此处输入图像描述 1 1
  3. You can create a file called bootstrap.custom.scss for testing.您可以创建一个名为bootstrap.custom.scss的文件进行测试。
    • You can right-click the bootstrap.custom.scss file and select Web Compiler->Compile file.您可以右键单击bootstrap.custom.scss文件和 select Web Compiler->Compile 文件。
      • If you cannot find the Web Compiler option , you need to click this link to install the Web Compiler tool , and then restart VS.如果找不到 Web 编译器选项,需要点击此链接安装 Web 编译器工具,然后重启VS。
    • bootstrap.custom.scss bootstrap.custom.scss
      •  $primary: #00ffff; $white:white; @import "../lib/bootstrap/scss/bootstrap"; nav.navbar { background: linear-gradient($primary, $white) }
    • Modify the _Layout view修改 _Layout 视图
      • ... ... @*<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />*@ <link href="~/css/bootstrap.custom.css" rel="stylesheet" />... ... @*<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>*@... ...
    • Result结果
      • 在此处输入图像描述

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

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