Lum*_*ack 5 radio-button blazor
我正在使用 Blazor 处理单选按钮。必须有 2 个单选按钮来称呼一个人。但此人的称呼已经很清楚了。例如,如果它是一个男人,我需要在加载页面时检查 man 单选按钮。问题是我不能@bind-Value用于单选按钮。谁能帮我?
请在此示例之后为您的代码建模:
@foreach (var choice in new[] { Choices.Red, Choices.Green, Choices.Blue })
{
<label>
<input name="yourColor" type="radio"
value="@choice"
checked="@(currentChoice == choice)"
@onchange="@(() => { currentChoice = choice; })">
@choice.ToString()
</label>
}
<p>You chose: @currentChoice</p>
@code {
enum Choices { Red, Green, Blue };
Choices currentChoice = Choices.Red;
}
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助...
来源:https : //github.com/dotnet/aspnetcore/issues/5579#issuecomment-548061223
| 归档时间: |
|
| 查看次数: |
2442 次 |
| 最近记录: |