Skip to content

Commit 75936f8

Browse files
committed
refactor: 代码重构
1 parent 51f0063 commit 75936f8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private async Task OnClickItem(string val)
126126
}
127127
}
128128

129-
private List<string> Rows => _filterItems ?? Items.ToList();
129+
private List<string> Rows => _filterItems ?? [.. Items];
130130

131131
/// <summary>
132132
/// TriggerFilter 方法
@@ -138,24 +138,24 @@ public override async Task TriggerFilter(string val)
138138
if (OnCustomFilter != null)
139139
{
140140
var items = await OnCustomFilter(val);
141-
_filterItems = items.ToList();
141+
_filterItems = [.. items];
142142
}
143143
else if (string.IsNullOrEmpty(val))
144144
{
145-
_filterItems = Items.ToList();
145+
_filterItems = [.. Items];
146146
}
147147
else
148148
{
149149
var comparison = IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
150150
var items = IsLikeMatch
151151
? Items.Where(s => s.Contains(val, comparison))
152152
: Items.Where(s => s.StartsWith(val, comparison));
153-
_filterItems = items.ToList();
153+
_filterItems = [.. items];
154154
}
155155

156156
if (DisplayCount != null)
157157
{
158-
_filterItems = _filterItems.Take(DisplayCount.Value).ToList();
158+
_filterItems = [.. _filterItems.Take(DisplayCount.Value)];
159159
}
160160
StateHasChanged();
161161
}

0 commit comments

Comments
 (0)