MudBlazor 的 MudChip 默认 true 不起作用



当从提取的API数据中呈现MudChip项时;默认";不起作用。你能帮我做这件事吗?

<MudChipSet @bind-SelectedChips="selected" MultiSelection="true" Filter="true">
<MudChip Text="Test1" Default="true" /> <!-- This works -->
<MudChip Text="Test2" Default="true" /> <!-- This works -->
@if (UserMenuList == null)
{
<MudChip Text="Loading..." Disabled="true" />
}
else
{
@foreach (var item in UserMenuList.OrderBy(o => o.Name))
{
<MudChip Text="@item.Name" Tag="item" Default="true" /> <!-- This does not -->
}
}
</MudChipSet>

这个问题在这个github问题中得到了跟踪和解决。如果您无法更新MudBlazor,解决方法是将整个芯片组封装在else语句中:

@if (UserMenuList == null)
{
<span>Loading ... </span>
}
else
{
<MudChipSet @bind-SelectedChips="selected" MultiSelection="true" Filter="true">
<MudChip Text="Test1" Default="true" /> 
<MudChip Text="Test2" Default="true" /> 
@foreach (var item in UserMenuList.OrderBy(o => o.Name))
{
<MudChip Text="@item.Name" Tag="item" Default="true" />
}
</MudChipSet>
}

相关内容

  • 没有找到相关文章

最新更新