Skip to content

Commit 0af2b3a

Browse files
committed
修复异步调用 StateHasChanged() 出错
1 parent 79fce04 commit 0af2b3a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
5555
}
5656
}
5757

58-
private Task Show(DialogOption option)
58+
private async Task Show(DialogOption option)
5959
{
6060
_onShownAsync = async () =>
6161
{
@@ -158,8 +158,7 @@ private Task Show(DialogOption option)
158158

159159
// Add ModalDialog to the container
160160
DialogParameters.Add(parameters, (_isKeyboard, _isBackdrop));
161-
StateHasChanged();
162-
return Task.CompletedTask;
161+
await InvokeAsync(StateHasChanged);
163162
}
164163

165164
private static RenderFragment RenderDialog(int index, Dictionary<string, object> parameter) => builder =>

0 commit comments

Comments
 (0)