首先,我正在使用Blazor WebAssembly 3.2.0 Preview 4
.
我有一个名为 ObjectList 的对象列表,每个对象都有一个名为principal
. 此列表填充一个表。
逻辑是列表中只有一个元素可以将principal
属性值设置为 true,因此这就是单选按钮非常理想的原因。
在此示例中,我使用 MatBlazor 作为控件库。
有没有办法将此属性的单选按钮放在表格中,如下面的代码所示?
<table class="table table-condensed">
<thead>
<tr>
<th>Object</th>
<th>Principal</th>
</tr>
</thead>
<tbody>
@foreach (var object in ObjectList)
{
<tr>
<td>@object .name</td>
<td>
<MatRadioButton TValue="bool" Value="@object.principal"></MatRadioButton>
</td>
</tr>
}
</tbody>
</table>