当从提取的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>
}