我正在使用 DinamicComponent 渲染组件,我需要调用在子组件中找到的函数。我找不到对 DinamicComponents 使用 @ref 的等价物,以便我可以引用来调用该函数。
这是父组件
<div class="tab-content">
@foreach (VerticalTabComponent.TabModel oneTabItem in VerticalTabsList)
{
<div class="tab-pane fade show @(oneTabItem.TabIndex == SelectedTabIndex ? "active" : "")" @key=@($"VTabDivDynamic_{TabPrefix}_{oneTabItem.TabIndex.ToString()}")>
<DynamicComponent
Type=@System.Type.GetType(oneTabItem.TabComponent)
Parameters=@oneTabItem.TabParameters>
</DynamicComponent>
</div>
}
</div>
这是 Blazor 组件选项卡中的代码
public partial class TabComponent
{
[Parameter]
public EventCallback<string> InsertUpdateCallback { get; set; }
protected override async Task OnInitializedAsync()
{
await CallAnyfunctionAsync();
}
private async Task<bool> LoadDataGrid()
{
//this is the function I need to call from parent
}
}
如何从父组件调用 Load Grid 函数?