Skip to content

Commit 3a14950

Browse files
committed
doc: 更新示例
1 parent a6ae320 commit 3a14950

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,29 @@
66
<DemoBlock Title="@Localizer["TransferNormalTitle"]"
77
Introduction="@Localizer["TransferNormalIntro"]"
88
Name="Normal">
9-
<Transfer TValue="string" Items="@Items" OnSelectedItemsChanged="@OnSelectedItemsChanged" />
9+
<section ignore class="row form-inline g-3">
10+
<div class="col-12 col-sm-6">
11+
<BootstrapInputGroup>
12+
<BootstrapInputGroupLabel DisplayText="IsWrapItem"></BootstrapInputGroupLabel>
13+
<Switch @bind-Value="_isWrapItem"></Switch>
14+
</BootstrapInputGroup>
15+
</div>
16+
<div class="col-12 col-sm-6">
17+
<BootstrapInputGroup>
18+
<BootstrapInputGroupLabel DisplayText="IsWrapItemText"></BootstrapInputGroupLabel>
19+
<Switch @bind-Value="_isWrapItemText"></Switch>
20+
</BootstrapInputGroup>
21+
</div>
22+
<div class="col-12 col-sm-6">
23+
<BootstrapInputGroup>
24+
<BootstrapInputGroupLabel DisplayText="ItemWidth"></BootstrapInputGroupLabel>
25+
<BootstrapInput @bind-Value="@_itemWidth"></BootstrapInput>
26+
</BootstrapInputGroup>
27+
</div>
28+
</section>
29+
<Transfer TValue="string" Items="@Items"
30+
IsWrapItem="_isWrapItem" IsWrapItemText="_isWrapItemText" ItemWidth="@_itemWidth"
31+
OnSelectedItemsChanged="@OnSelectedItemsChanged" />
1032
<ConsoleLogger @ref="Logger" />
1133
</DemoBlock>
1234

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public sealed partial class Transfers : ComponentBase
4343

4444
private IEnumerable<SelectedItem> SelectedValue { get; set; } = Enumerable.Empty<SelectedItem>();
4545

46+
private bool _isWrapItem = true;
47+
private bool _isWrapItemText = true;
48+
private string? _itemWidth = "160px";
49+
4650
private Task OnSelectedItemsChanged(IEnumerable<SelectedItem> items)
4751
{
4852
Logger.Log(string.Join(" ", items.Select(i => i.Text)));
@@ -59,15 +63,17 @@ protected override async Task OnInitializedAsync()
5963
// 模拟异步加载数据源
6064
await Task.Delay(100);
6165

62-
Items = GeneratorItems();
66+
var items = GeneratorItems().ToList();
67+
items[1].Text = "我是一个超级长的专门为了测试溢出折行功能的候选项";
68+
Items = items;
6369
Items1 = GeneratorItems();
6470
Items2 = GeneratorItems();
6571

66-
Items3 = Enumerable.Range(1, 15).Select(i => new SelectedItem()
72+
Items3 = [.. Enumerable.Range(1, 15).Select(i => new SelectedItem()
6773
{
6874
Text = $"{Localizer["Backup"]} {i:d2}",
6975
Value = i.ToString()
70-
}).ToList();
76+
})];
7177

7278
Items4 = GeneratorItems();
7379
Items5 = GeneratorItems();

0 commit comments

Comments
 (0)