0
<MudIcon Icon="@inboxIcon" Color="Color.Primary" />
@code{

   // here this Icon string is coming from database
   
private string inboxIcon = "Icons.Material.Filled.Inbox"; 

}

上面的代码没有显示任何图标。如何绑定此图标字符串?

4

1 回答 1

0

你快到了。试试这样:

<MudIcon Icon="@inboxIcon" Color="Color.Primary" />


@code{

   // here this Icon string is coming from database
   
private string inboxIcon = MudBlazor.Icons.Material.Filled.Inbox; 

}

命名空间中的Icons会自动转换成字符串。

于 2021-12-21T10:30:04.433 回答