在Blazor中,如果您希望当用户选择
public class SelectOption
{
public string Value { get; set; }
public string Text { get; set; }
}
public class MyFormModel
{
public string SelectedOptionValue { get; set; }
// 其他属性...
}
@code {
private List selectOptions = new List
{
new SelectOption { Value = "option1", Text = "Option 1" },
new SelectOption { Value = "option2", Text = "Option 2" },
// 其他选项...
};
private MyFormModel myFormModel = new MyFormModel();
}
现在,当用户选择