HtmlRole 特性

快速设置 HTML 元素作为 role="xxx" 的属性

Anchor.razor
@inherits BlazorComponentBase
@attribute [HtmlRole("button")]

<a @attribute="@AdditionalAttributes">@ChildContent</a>

@code{    
    [Parameter]public RenderFragment? ChildContent { get; set; }
}
Anchor.cs

[HtmlRole("button")]
public class Anchor : BlazorComponentBase, IHasChildContent
{    
    [Parameter]public RenderFragment? ChildContent { get; set; }
}
Index.razor
<Anchor></Anchor>

<a role="button"></a>

Last updated