<Form Model="@model"
OnFinish="OnFinish"
OnFinishFailed="OnFinishFailed"
LabelColSpan="4"
WrapperColSpan="8">
<FormItem Label="分类名称">
<Input @ref="@categoryTextRef" @bind-Value="@context.Category" />
</FormItem>
<FormItem WrapperColOffset="4" WrapperColSpan="8">
<Button Type="@ButtonType.Primary" HtmlType="submit">
提交
</Button>
</FormItem>
</Form>
@code
{
private NoteCategory model = new NoteCategory();
ElementReference categoryTextRef;
private async void OnFinish(EditContext editContext)
{
NoteCategory noteCategory = editContext.Model as NoteCategory;
Console.WriteLine($"Success:{JsonSerializer.Serialize(model)}");
await Http.PostAsJsonAsync<NoteCategory>("NoteCategory/add", noteCategory);
model.Category = string.Empty;
model.SerialNumber++;
await categoryTextRef.FocusAsync();
//await categoryText.Element.Value.FocusAsync();
}
}