mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-05 21:50:05 +08:00
!795 feat(#I2AGVU): add OnValueChanged delegate on Toggle/Switch
* docs: 更新 Toggle/Switch OnValueChanged 文档 * feat: Toggle 组件增加 OnValueChanged 回调委托
This commit is contained in:
parent
d26df34bda
commit
7c8ab6e1fd
@ -155,6 +155,13 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
ValueList = " — ",
|
||||
DefaultValue = " — "
|
||||
},
|
||||
new AttributeItem() {
|
||||
Name = "OnValueChanged",
|
||||
Description = "值发生改变时回调委托方法",
|
||||
Type = "Func<bool, Task>",
|
||||
ValueList = " — ",
|
||||
DefaultValue = " — "
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@ -168,7 +175,7 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
Name = "ValueChanged",
|
||||
Description="获取选择改变的值",
|
||||
Type ="EventCallback<bool>"
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
Name = "ValueChanged",
|
||||
Description="获取选择改变的值",
|
||||
Type ="EventCallback<bool>"
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@ -127,6 +127,13 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
ValueList = " — ",
|
||||
DefaultValue = " — "
|
||||
},
|
||||
new AttributeItem() {
|
||||
Name = "OnValueChanged",
|
||||
Description = "值发生改变时回调委托方法",
|
||||
Type = "Func<bool, Task>",
|
||||
ValueList = " — ",
|
||||
DefaultValue = " — "
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
// **********************************
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -67,6 +68,12 @@ namespace BootstrapBlazor.Components
|
||||
[Parameter]
|
||||
public Color Color { get; set; } = Color.Success;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public Func<bool, Task>? OnValueChanged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点击控件时触发此方法
|
||||
/// </summary>
|
||||
@ -76,6 +83,7 @@ namespace BootstrapBlazor.Components
|
||||
{
|
||||
Value = !Value;
|
||||
if (ValueChanged.HasDelegate) await ValueChanged.InvokeAsync(Value);
|
||||
OnValueChanged?.Invoke(Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user