Bootstrap Blazor 組件入門


Bootstrap Blazor 是一套企業級 UI 組件庫,適配移動端支持各種主流瀏覽器,已經在多個交付項目中使用。通過本套組件可以大大縮短開發周期,節約開發成本。目前已經開發、封裝了 70 多個組件,歡迎有興趣的同學試用。

Gitee 開源地址為:https://gitee.com/LongbowEnterprise/BootstrapBlazor
Github 開源地址為:https://github.com/ArgoZhang/BootstrapBlazor

在線演示網站:https://www.blazor.zone

安裝指南

項目模板

  1. 安裝模板

dotnet new -i Bootstrap.Blazor.Templates::*

  1. 使用項目模板創建新項目

dotnet new bbapp

bbapp 是 BootstrapBlazor App 的縮寫

  1. 卸載項目模板

dotnet new -u Bootstrap.Blazor.Templates

現有項目中集成 BootstrapBlazor

  1. 從 Nuget.org 獲取 BootstrapBlazor 包

dotnet add package BootstrapBlazor

  1. 添加樣式文件與腳本到項目文件中 Pages/_Host.cshtml (Server) or wwwroot/index.html (WebAssembly)

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    . . .
    <link rel="stylesheet" href="_content/BootstrapBlazor/css/bootstrap.blazor.bundle.min.css">
</head>
<body>
    . . .
    <script src="_framework/blazor.server.js"></script>
    <script src="_content/BootstrapBlazor/js/bootstrap.blazor.bundle.min.js"></script>
</body>
</html>
  1. 注冊服務 ~/Startup.cs

C#

namespace BootstrapBlazorAppName
{
    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            //more code may be present here
            services.AddBootstrapBlazor(); 
        }

        //more code may be present here
    }
}

Visual Studio 插件

安裝 Visual Studio 插件

安裝包

下載地址

使用教程

  1. 下載安裝包
  2. 解壓縮安裝包
  3. 安裝 vsix 插件

雙擊 BootstrapBlazor.UITemplate.vsix 文件,請保證 Visual Studio IDE 以及相關進程均關閉,此安裝包安裝過程可能很慢,請耐心等待

特別注意

如果長時間無響應,請查看任務管理器中是否有 devenv.exe 或者 msbuild.exe 進程,如果有請手動結束

  1. 打開 Visual Studio 2019
  1. 選中 Server 或者 WebAssembly 工程直接運行 F5
  1. 項目中按照自己需求更改頁面


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM