dotnet/aspnetcore

Suggestion: Expose a parameter of `ShouldMatch` for `<NavLink />`

已关闭

#18,163 创建于 2020年1月7日

 (6 条评论) (1 个反应) (0 位负责人)C# (10,653 个派生)batch import
Priority:1affected-fewarea-blazorenhancementfeature-blazor-builtin-componentshelp wantedseverity-minor

仓库指标

星标
 (37,933 个星标)
PR 合并指标
 (平均合并 16天 9小时) (30 天内合并 258 个 PR)

描述

Is your feature request related to a problem? Please describe.

I want to custom the matching behavior of <NavLink />.

Let's say we want to process a url with a hash(See this thread on SO) :

http://localhost/#an-element-id

Sometimes we might think this url matches http://localhost , while some other users don't think so.

It would be great if we are allowed to custom this matching behavior. Usually, we can custom by inheritance or composition. However, the matching logic is hardcoded for the present.

  1. There's no public/protected ShouldMatch(string) method exposed. So it's difficult to achieve it by inheritance
  2. There's no ShouldMatch parameter exposed. It would be great if we can pass a ShouldMatch [Parameter] to this component.

Describe the solution you'd like

Expose a [Parameter] of ShouldMatch(string):

  • if user provides such a parameter, use it.
  • Otherwise, use the default logic.

贡献者指南