在我的blazer应用程序中,我正在对后端服务器进行api调用,这可能需要一些时间。我需要向用户显示反馈,等待光标或“旋转”图像。在Blazor中如何进行?
我尝试使用CSS并打开和关闭CSS,但是直到调用完成,页面才会刷新。任何建议将不胜感激。
@functions {
UserModel userModel = new UserModel();
Response response = new Response();
string errorCss = "errorOff";
string cursorCSS = "cursorSpinOff";
protected void Submit()
{
//Show Sending...
cursorCSS = "";
this.StateHasChanged();
response = Service.Post(userModel);
if (response.Errors.Any())
{
errorCss = "errorOn";
}
//turn sending off
cursorCSS = "cursorSpinOff";
this.StateHasChanged();
}
}
Run Code Online (Sandbox Code Playgroud)