mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-05 13:39:39 +08:00
!2263 refactor(#I4OJRD): redesign Tab component
* doc: 格式化文档 * refactor: 更新 TabLink 内部逻辑
This commit is contained in:
parent
4278593c31
commit
d9c5f0cfbe
@ -1,7 +1,4 @@
|
||||
@namespace BootstrapBlazor.Components
|
||||
@inherits BootstrapComponentBase
|
||||
|
||||
@if (ChildContent != null)
|
||||
{
|
||||
<a @attributes="@AdditionalAttributes" href="@Url" @onclick="@OnClickLink">@ChildContent</a>
|
||||
}
|
||||
<a @attributes="@AdditionalAttributes" href="@Url" @onclick="@OnClickLink">@RenderChildContent()</a>
|
||||
|
@ -65,5 +65,27 @@ namespace BootstrapBlazor.Components
|
||||
TabItemOptions.Text = Text;
|
||||
TabItemOptions.Closable = Closable;
|
||||
}
|
||||
|
||||
private RenderFragment RenderChildContent() => builder =>
|
||||
{
|
||||
var index = 0;
|
||||
if (ChildContent == null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Icon))
|
||||
{
|
||||
builder.OpenElement(index++, "i");
|
||||
builder.AddAttribute(index++, "class", Icon);
|
||||
builder.CloseElement();
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Text))
|
||||
{
|
||||
builder.AddContent(index++, Text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AddContent(index++, ChildContent);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,13 @@ using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace BootstrapBlazor.Components
|
||||
namespace BootstrapBlazor.Components;
|
||||
|
||||
/// <summary>
|
||||
/// NavigationManager 扩展方法
|
||||
/// </summary>
|
||||
public static class NavigationManagerExtensions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class NavigationManagerExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 导航并添加 TabItem 方法
|
||||
/// </summary>
|
||||
@ -31,5 +31,4 @@ namespace BootstrapBlazor.Components
|
||||
option.Closable = closable ?? true;
|
||||
navigation.NavigateTo(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user