diff --git a/src/BootstrapBlazor/Components/Button/ButtonBase.cs b/src/BootstrapBlazor/Components/Button/ButtonBase.cs index 89ceb67e5e89a10dfceeba0d49065f08502dc417..2462809386b5712c03766d31044208948e8dbf1e 100644 --- a/src/BootstrapBlazor/Components/Button/ButtonBase.cs +++ b/src/BootstrapBlazor/Components/Button/ButtonBase.cs @@ -211,4 +211,29 @@ public abstract class ButtonBase : TooltipComponentBase IsDisabled = disable; StateHasChanged(); } + + /// + /// 显示 Tooltip 方法 + /// + /// + /// + public virtual async Task ShowTooltip(string message) + { + if (!string.IsNullOrEmpty(Id)) + { + await JSRuntime.InvokeVoidAsync(null, "bb_tooltip", Id, "show", message, "auto", false, "focus"); + } + } + + /// + /// 销毁 Tooltip 方法 + /// + /// + public virtual async Task RemoveTooltip() + { + if (!string.IsNullOrEmpty(Id)) + { + await JSRuntime.InvokeVoidAsync(null, "bb_tooltip", Id, "dispose"); + } + } } diff --git a/test/UnitTest/Components/ButtonTest.cs b/test/UnitTest/Components/ButtonTest.cs index b11ead5272c3edeecec49891c0fc6625eda4f70e..bd69746b4574c58fce57c7b46d7c9999d76dd3ac 100644 --- a/test/UnitTest/Components/ButtonTest.cs +++ b/test/UnitTest/Components/ButtonTest.cs @@ -321,4 +321,18 @@ public class ButtonTest : BootstrapBlazorTestBase await tcs.Task; Assert.True(valid); } + + [Fact] + public async Task ShowTooltip_Ok() + { + var cut = Context.RenderComponent