Skip to content

Commit d949c98

Browse files
committed
fix: 修复数据源为 null 时赋值逻辑
1 parent 313b0ba commit d949c98

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/BootstrapBlazor/Components/Cascader/Cascader.razor.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,16 @@ protected override void OnParametersSet()
133133
SubMenuIcon ??= IconTheme.GetIconByKey(ComponentIcons.CascaderSubMenuIcon);
134134
ClearIcon ??= IconTheme.GetIconByKey(ComponentIcons.SelectClearIcon);
135135

136-
Items ??= [];
137-
138136
PlaceHolder ??= Localizer[nameof(PlaceHolder)];
139137

138+
Items ??= [];
139+
if (!Items.Any())
140+
{
141+
_lastValue = string.Empty;
142+
Value = default;
143+
return;
144+
}
145+
140146
if (_lastValue != CurrentValueAsString)
141147
{
142148
_lastValue = CurrentValueAsString;

0 commit comments

Comments
 (0)