我在浏览器中收到以下错误:
Cannot provide a value for property 'IconService' on type 'Microsoft.Fast.Components.FluentUI.FluentIcon'. There is no registered service of type 'Microsoft.Fast.Components.FluentUI.IconService'.
https://learn.microsoft.com/en-us/fluent-ui/web-components/components/button?pivots=blazor
https://github.com/microsoft/fast-blazor/blob/main/examples/FluentUI.Demo.Shared/Pages/ButtonPage.razor
https://brave-cliff-0c0c93310.azurestaticapps.net/ButtonPage
这是在使用Microsoft Blazor的示例代码时:
<h3>With content and icon</h3>
<h4>With start</h4>
<FluentButton>
Button
<FluentIcon Name="@FluentIcons.Globe" Slot="start" Size="@IconSize.Size16" Filled=false />
</FluentButton>
一个按钮可以很好地显示,但当我使用FluentIcon
时,会出现运行时错误。
我遵循了以下入门指南:
https://learn.microsoft.com/en-us/fluent-ui/web-components/integrations/blazor
我也看过图标的例子,但没有运气:
https://brave-cliff-0c0c93310.azurestaticapps.net/IconPage
您需要将下面的代码添加到Blazor客户端的Program.cs
中。出于某种原因,这只记录在Github上,但没有https://learn.microsoft.com.
builder.Services.AddFluentUIComponents();
https://github.com/microsoft/fast-blazor