!819 feat(#I2AYEQ): add Match property on MenuItem

* feat: MenuItem 增加 Match 属性
This commit is contained in:
Argo 2020-12-27 01:29:05 +08:00
parent 1d12fa8a7d
commit e361ffb365
3 changed files with 8 additions and 2 deletions

View File

@ -7,6 +7,7 @@
// 开源协议Apache-2.0 (https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/dev/LICENSE)
// **********************************
using Microsoft.AspNetCore.Components.Routing;
using System.Collections.Generic;
using System.Linq;
@ -63,6 +64,11 @@ namespace BootstrapBlazor.Components
/// </summary>
public string? Icon { get; set; }
/// <summary>
/// 获得/设置 匹配方式 默认 NavLinkMatch.Prefix
/// </summary>
public NavLinkMatch Match { get; set; }
/// <summary>
/// 获得/设置 菜单内子组件
/// </summary>

View File

@ -1,7 +1,7 @@
@namespace BootstrapBlazor.Components
@inherits BootstrapComponentBase
<NavLink @attributes="@AdditionalAttributes" class="@ClassString" href="@GetHrefString" @onclick="@OnClickLink" Match="@GetMatch()" data-match="@GetMatch()">
<NavLink @attributes="@AdditionalAttributes" class="@ClassString" href="@GetHrefString" @onclick="@OnClickLink" Match="@GetMatch()">
@if (!string.IsNullOrEmpty(Item.Icon))
{
<i class="@Item.Icon"></i>

View File

@ -53,6 +53,6 @@ namespace BootstrapBlazor.Components
if (OnClick != null) await OnClick(Item);
}
private NavLinkMatch GetMatch() => string.IsNullOrEmpty(Item.Url) ? NavLinkMatch.All : NavLinkMatch.Prefix;
private NavLinkMatch GetMatch() => string.IsNullOrEmpty(Item.Url) ? NavLinkMatch.All : Item.Match;
}
}