我有一个基本组件,如下所示:
CatalogTableBase.razor.cs(CatalogTableBase.razor的代码后面)
public class CatalogTableBase<T>
{
[Parameter]
public IEnumerable<Feature<T>>? FeatureList { get; set; }
[Parameter]
public List<string>? FeatureGroupProperties { get; set; }
[Parameter]
public bool ShowHeader { get; set; } = true;
}
现在,我想创建两个不同的子组件,它们曾经将string
实现为一般传递的类型,并且曾经实现为double
.
FeatureRangeCatalogTable.razor个
@inherits CatalogTableBase<double>
<div>
...
</div>
This throws the CS0115 Error. (FeatureRangeCatalogTable.BuildRenderTree(RenderTreeBuilder): no suitable method found to override)
I guess the thrown error has something to do with the interpreter not knowing what to do with the @inherits
-line.
I can't wrap around my head why this wouldn't work. Inheriting the class in the code behind (FeatureRangeCatalogTable.razor.cs
) also doesn't work.
TL:DR
如何在Blazor组件中实现泛型基类?