简体   繁体   English

如何在 C# Blazor WebAssembly 中使用引导图标?

[英]How do I use Bootstrap Icons in C# Blazor WebAssembly?

I'm making a Blazor WebAssembly website in Microsoft Visual Studio 2022 and I'm having some trouble getting the bootstrap icons to show up on the navmenu.我正在 Microsoft Visual Studio 2022 中创建 Blazor WebAssembly 网站,但在导航菜单上显示引导图标时遇到了一些问题。 I installed the icons via npm and copied the bootstrap folder to my wwwroot in the project viewer.我通过 npm 安装了图标,并将引导文件夹复制到项目查看器中的 wwwroot 中。

My code for the navmenu item looks like this:我的导航菜单项代码如下所示:

<div class="nav-item px-3">
            <NavLink class="nav-link" href="Spotify">
                <span class="bi bi-spotify" aria-hidden="true"></span> Spotify
            </NavLink>
    </div>

The default for the span class was span class="oi oi-plus" and it ran fine and that icon showed up, but when I run the program with the new span class code as above, the icon doesn't show up on next to the text or anywhere at all. span 类的默认值是span class="oi oi-plus"并且运行良好并且显示了该图标,但是当我使用上面的新 span 类代码运行程序时,该图标不会出现在 next到文本或任何地方。

You need only copy bootstrap-icons.svg from bootstraps repo .您只需要从 bootstrap repo复制 bootstrap-icons.svg 。 Put this in a folder within your wwwroot folder.将其放在wwwroot文件夹中的文件夹中。

For example to create emoji-smile-fill use.例如创建emoji-smile-fill使用。

<svg class="bi" width="24" height="24" fill="currentColor" >
    <use href="{folder-to-resource}/bootstrap-icons.svg#emoji-smile-fill"></use>
</svg>

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

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