Blazor InputRadio



当我们在一个InputRadioGroup,如何有一个单选按钮默认检查?这似乎不工作:

<InputRadio class="mr-1" Name="Selected" Value="@("General")" checked="checked"></InputRadio>

@bind-Value="@_model.SelectedManufacturer"在InputRadioGroup中设置组的值,下面的代码将在开始时将选中的单选按钮设置为tesla,就像它在FormClass

中设置的那样
<EditForm Model="_model">
<InputRadioGroup @bind-Value="@_model.SelectedManufacturer">
Manufacturer:
<br>
@foreach (var manufacturer in Manufacturers)
{
<InputRadio Value="manufacturer" />
@manufacturer
<br>
}
</InputRadioGroup>
</EditForm>

@code {
List<String> Manufacturers = new List<string> { "Ford", "Toyota", "Tesla" };
FormClass _model = new FormClass();
class FormClass
{
public  String SelectedManufacturer { get; set; } = "Tesla";
}
}

相关内容

  • 没有找到相关文章

最新更新