我使用的是 mudblazor 6.10.0,我遇到了对话框未显示的问题,即使我使用开箱即用的对话框也无法打开。我在控制台上没有收到错误,代码中也没有发生错误,但对话框根本不显示。单击按钮会调用 ToggleOpen 代码,但不显示对话框。
我的组件
@using Microsoft.AspNetCore.Components
@using MudBlazor
<MudDialog>
<TitleContent>
<MudText Typo="Typo.h6">
<MudIcon Icon="@Icons.Material.Outlined.Edit" Class="mr-3 mb-n1"/>
Changes made by @User.Name
</MudText>
</TitleContent>
<DialogContent>
<MudTextField Disabled="true" Label="Before" @bind-Value="User.Change" Multiline="true" />
</DialogContent>
<DialogActions>
<MudButton Color="Color.Primary" OnClick="Close">Ok</MudButton>
</DialogActions>
</MudDialog>
@code {
[CascadingParameter] MudDialogInstance MudDialog { get; set; }
[Parameter]
public UserChange User { get; set; }
private void Close() => MudDialog.Close(DialogResult.Ok(true));
}
Run Code Online (Sandbox Code Playgroud)
与调用父组件
@page "/"
@using MudBlazor
@inject UserChangesService UserChangesService
@inject IDialogService DialogService
<MudText Typo="Typo.h2" Color="Color.Info">Welcome</MudText>
<MudGrid>
<MudItem xs="12" sm="6">
<MudCard> …Run Code Online (Sandbox Code Playgroud)