diff --git a/components/cascader/Cascader.razor.cs b/components/cascader/Cascader.razor.cs index af0df71b..a8d39c38 100644 --- a/components/cascader/Cascader.razor.cs +++ b/components/cascader/Cascader.razor.cs @@ -326,7 +326,8 @@ namespace AntDesign var node = GetNodeByValue(_nodelist, defaultValue); SetSelectedNodeWithParent(node, ref _selectedNodes); _renderNodes = _selectedNodes; - SetValue(node.Value); + if (node != null) + SetValue(node.Value); } /// diff --git a/components/date-picker/DatePicker.Razor.cs b/components/date-picker/DatePicker.Razor.cs index 4d511b5a..b6c24bae 100644 --- a/components/date-picker/DatePicker.Razor.cs +++ b/components/date-picker/DatePicker.Razor.cs @@ -5,6 +5,16 @@ namespace AntDesign { public partial class DatePicker : DatePickerBase { + protected override void OnInitialized() + { + base.OnInitialized(); + if (Value != null && Value != DateTime.MinValue) + { + ChangeValue(Value, 0); + } + } + + protected void OnInput(ChangeEventArgs args, int index = 0) { if (args == null) diff --git a/components/date-picker/internal/DatePickerBase.cs b/components/date-picker/internal/DatePickerBase.cs index 4c770ecc..2cce32e2 100644 --- a/components/date-picker/internal/DatePickerBase.cs +++ b/components/date-picker/internal/DatePickerBase.cs @@ -451,7 +451,7 @@ namespace AntDesign public void Close() { - _dropDown.Hide(); + _dropDown?.Hide(); } public async Task Focus(int index = 0) @@ -559,6 +559,11 @@ namespace AntDesign StateHasChanged(); } + /// + /// 修改值 + /// + /// + /// public virtual void ChangeValue(DateTime value, int index = 0) { } diff --git a/components/input-number/InputNumber.razor.cs b/components/input-number/InputNumber.razor.cs index 799bd773..de01875d 100644 --- a/components/input-number/InputNumber.razor.cs +++ b/components/input-number/InputNumber.razor.cs @@ -140,7 +140,7 @@ namespace AntDesign { base.OnInitialized(); SetClass(); - CurrentValue = DefaultValue; + CurrentValue = Value ?? DefaultValue; } private void SetClass() diff --git a/components/switch/Switch.razor.cs b/components/switch/Switch.razor.cs index 4d2b1209..e85a45b6 100644 --- a/components/switch/Switch.razor.cs +++ b/components/switch/Switch.razor.cs @@ -49,7 +49,7 @@ namespace AntDesign protected override void OnInitialized() { - this._isChecked = Checked; + this._isChecked = Value ? Value : Checked; base.OnInitialized(); } diff --git a/site/AntBlazor.Docs/Demos/Form/demo/Size.razor b/site/AntBlazor.Docs/Demos/Form/demo/Size.razor index b6cac5c1..9db52b63 100644 --- a/site/AntBlazor.Docs/Demos/Form/demo/Size.razor +++ b/site/AntBlazor.Docs/Demos/Form/demo/Size.razor @@ -1,77 +1,85 @@ @using System.Text.Json; -
- - - Small - Default - Large - - + + + + Small + Default + Large + + - - - - -