Skip to content

Commit 6f6fb08

Browse files
committed
refactor: 重构代码
1 parent c87e62a commit 6f6fb08

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/BootstrapBlazor/Components/AutoFill/AutoFill.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<span class="form-select-append"><i class="@Icon"></i></span>
1919
<span class="form-select-append ac-loading"><i class="@LoadingIcon"></i></span>
2020
<ul class="dropdown-menu">
21-
@foreach (var item in _filterItems)
21+
@foreach (var item in Rows)
2222
{
2323
<li @key="@item" class="dropdown-item" @onclick="() => OnClickItem(item)">
2424
@if (ItemTemplate != null)
@@ -31,7 +31,7 @@
3131
}
3232
</li>
3333
}
34-
@if (ShowNoDataTip && _filterItems.Count == 0)
34+
@if (ShowNoDataTip && Rows.Count == 0)
3535
{
3636
<li class="dropdown-item">@NoDataTip</li>
3737
}

src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ protected override void OnParametersSet()
118118
OnGetDisplayText ??= v => v?.ToString();
119119
_displayText = Value is null ? "" : OnGetDisplayText(Value);
120120

121-
_filterItems ??= Items?.ToList() ?? [];
121+
Items ??= [];
122122
}
123123

124124
/// <summary>
@@ -135,6 +135,8 @@ private async Task OnClickItem(TValue val)
135135
}
136136
}
137137

138+
private List<TValue> Rows => _filterItems ?? Items.ToList();
139+
138140
/// <summary>
139141
/// TriggerFilter 方法
140142
/// </summary>

0 commit comments

Comments
 (0)