ant-design-blazor/components/menu/MenuItem.razor

40 lines
1.1 KiB
C#
Raw Normal View History

@namespace AntDesign
@inherits AntDomComponentBase
2019-12-09 00:25:22 +08:00
<CascadingValue Value="this" IsFixed>
<Tooltip Title="@content(this)" Placement="@PlacementType.Right" Disabled="TooltipDisabled">
<Unbound>
<li class="@ClassMapper.Class" role="menuitem" style=" @(PaddingLeft>0? $"padding-left:{PaddingLeft}px;":"") @Style" @onclick="HandleOnClick" @key="Key" @ref="context.Current">
@if (Icon != null)
{
<Icon Type="@Icon" />
}
@if (RouterLink == null)
{
@content(this)
}
else
{
<MenuLink Href="@RouterLink" Match="@RouterMatch">@content(this)</MenuLink>
}
</li>
</Unbound>
</Tooltip>
</CascadingValue>
@code {
RenderFragment<MenuItem> content = item =>@<Template>
<span>
@if (item.Title != null)
{
@item.Title
}
else
{
@item.ChildContent
}
</span>
</Template>;
}