首先,我对我的英语水平感到非常抱歉。
我目前正在通过 dotnet core 3.1 blazor 开发一个 Web 项目。
如下面的源代码所示,我使用 IJSRuntime 调用需要很长时间的 Javascript 函数。
[Inject]
IJSRuntime JSRuntime { get; set; }
private async Task BtnDisplay()
await JSRuntime.InvokeVoidAsync("RefreshWebJS", Data);
}
Run Code Online (Sandbox Code Playgroud)
Javascript 函数需要很长时间,因此我添加了下面的源代码来添加微调器。
private async Task BtnDisplay()
{
showLoadingImg = true; // add
await JSRuntime.InvokeVoidAsync("RefreshWebJS", Data);
showLoadingImg = false;
}
Run Code Online (Sandbox Code Playgroud)
Spinner 在 razor 页面上定义如下:
@if (showLoadingImg == true)
{
<div style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; text-align: center;">
<img src="/images/LoadingImg.gif" style="position: absolute; top: 50%; left: 50%;" />
</div> …
Run Code Online (Sandbox Code Playgroud) blazor asp.net-core-signalr asp.net-core-3.1 blazor-jsinterop