Skip to content

Commit 9115124

Browse files
authored
fix: 调整bind-value:after不兼容低版本的写法 (#801)
1 parent 558a206 commit 9115124

2 files changed

Lines changed: 29 additions & 6 deletions

File tree

src/Masa.Stack.Components/Shared/IntegrationComponents/Confirm/SSimpleConfirm.razor

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@inherits Masa.Blazor.Popup.Components.AlertingPopupComponentBase
22

3-
<MDialog @bind-Value="@Visible"
4-
@bind-Value:after="OnVisibleChanged"
3+
<MDialog Value="@Visible"
4+
ValueChanged="OnVisibleChanged"
55
Class="pa-6"
66
ContentClass="pa-6 white rounded-5"
77
Width="400">
@@ -22,7 +22,7 @@
2222
<SIcon>mdi-close</SIcon>
2323
</MButton>
2424
</div>
25-
}
25+
}
2626
</div>
2727
<div class="regular2--text btn text-start my-3 px-9 @ContentClass">
2828
@Content
@@ -38,7 +38,7 @@
3838

3939
</MDialog>
4040

41-
@code {
41+
@code {
4242

4343
[Parameter]
4444
public string? Title { get; set; }
@@ -72,9 +72,10 @@
7272

7373
private string ComputedCancelText => CancelText ?? T("Cancel");
7474
private string ComputedOkText => OkText ?? T("Ok");
75-
76-
private async Task OnVisibleChanged()
75+
76+
private async Task OnVisibleChanged(bool value)
7777
{
78+
Visible = value;
7879
if (!Visible)
7980
{
8081
await SetResult(false);

tests/MasaWasmApp/Pages/Users.razor

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@inject MasaBlazor MasaBlazor
22
@inject IJSRuntime JSRuntime
33
@page "/users"
4+
@using Masa.Stack.Components.Extensions
45

56
<ul>
67
<li><a href="/users/1?a=1">User 1</a></li>
@@ -10,6 +11,14 @@
1011
<li><a href="/users/5">User 5</a></li>
1112
</ul>
1213

14+
<SButton Icon OnClick="ShowConfirmAsync">
15+
<SIcon>
16+
mdi-open-in-new
17+
</SIcon>
18+
19+
</SButton>
20+
21+
1322

1423
<SDateTimeRangeToolbar ShowTimeZoneSelector ShowQuickChange></SDateTimeRangeToolbar>
1524

@@ -132,6 +141,8 @@
132141
</MThemeProvider>
133142

134143
@code {
144+
[Inject]
145+
IPopupService PopupService { get; set; } = default!;
135146

136147
private StringNumber _themeName = "light";
137148
private ThemeOptions? _currentThemeOptions;
@@ -211,4 +222,15 @@
211222
}
212223
};
213224

225+
private async Task ShowConfirmAsync()
226+
{
227+
if (await PopupService.SimpleConfirmAsync("确认提示"))
228+
{
229+
await PopupService.EnqueueSnackbarAsync("OK");
230+
}
231+
else
232+
{
233+
await PopupService.EnqueueSnackbarAsync("Cancel");
234+
}
235+
}
214236
}

0 commit comments

Comments
 (0)