-
Notifications
You must be signed in to change notification settings - Fork 161
/
CustomDialog2.razor
41 lines (34 loc) · 989 Bytes
/
CustomDialog2.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<head>
<link href="css/CustomDialog2.css" rel="stylesheet" />
</head>
@if (ShowDialog)
{
<div class="custom-dialog-overlay" @onclick="HideDialog">
<div class="custom-dialog">
<h3>@DialogTitle</h3>
<p>@DialogContent</p>
<button class="btn btn-primary" @onclick="HideDialog">确定</button>
</div>
</div>
}
@code {
[Parameter]
public bool ShowDialog { get; set; }
[Parameter]
public string DialogTitle { get; set; }
[Parameter]
public string DialogContent { get; set; }
private void HideDialog()
{
ShowDialog = false;
// 触发一个事件,通知父组件弹窗已关闭
// OnDialogClosed?.InvokeAsync(null); // 如果需要的话
}
[Parameter]
public EventCallback OnDialogClosed { get; set; }
private async Task HideDialogAsync()
{
ShowDialog = false;
await OnDialogClosed.InvokeAsync(null); // 触发事件回调
}
}