Skip to content

Commit b262c4e

Browse files
committed
doc: 更新示例
1 parent 0fc543e commit b262c4e

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/BootstrapBlazor.Server/Components/Samples/ImageCroppers.razor

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,20 @@
1717
<Button Text="@Localizer["ImageCropperDisabledText"]" OnClick="_cropper.Disable" />
1818
<Button Text="@Localizer["ImageCropperClearText"]" OnClick="_cropper.Clear" />
1919
</BootstrapInputGroup>
20-
<Textarea Value="@_base64String" rows="3" class="mt-3" />
20+
@if (!string.IsNullOrEmpty(_base64String))
21+
{
22+
<img src="@_base64String" style="width: 240px;" />
23+
<Textarea Value="@_base64String" rows="3" class="mt-3" />
24+
}
2125
</section>
2226
</DemoBlock>
2327

2428
<DemoBlock Title="@Localizer["ImageCropperNormalText"]" Introduction="@Localizer["ImageCropperNormalIntro"]" Name="Normal">
25-
<ImageCropper Url="@images[0]" CropperShape="ImageCropperShape.Round" />
29+
<ImageCropper Url="@images[0]" CropperShape="ImageCropperShape.Round" OnCropAsync="OnCropAsync" />
30+
@if (!string.IsNullOrEmpty(_base64String2))
31+
{
32+
<img src="@_base64String2" style="width: 240px;" />
33+
}
2634
</DemoBlock>
2735

2836
<AttributeTable Items="@GetAttributes()" />

src/BootstrapBlazor.Server/Components/Samples/ImageCroppers.razor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public partial class ImageCroppers
1717

1818
private string? _base64String;
1919

20+
private string? _base64String2;
21+
2022
private async Task OnClickReplace()
2123
{
2224
index = index == 0 ? 1 : 0;
@@ -28,6 +30,13 @@ private async Task Crop()
2830
_base64String = await _cropper.Crop();
2931
}
3032

33+
private Task OnCropAsync(ImageCropperResult result)
34+
{
35+
_base64String2 = result.Data;
36+
StateHasChanged();
37+
return Task.CompletedTask;
38+
}
39+
3140
private Task Rotate() => _cropper.Rotate(90);
3241

3342
/// <summary>

0 commit comments

Comments
 (0)