Blazor子组件调用父方法
父
<h3>Parent Count: @currentCount</h3> <TestC onDoneClick="CToP" ></TestC> public int currentCount = 0; void CToP() { currentCount++; }
子
<button class="btn btn-primary" @onclick="DoneClick">方法调用</button> [Parameter] public EventCallback onDoneClick { get; set; } public async Task DoneClick() { await onDoneClick.InvokeAsync(); }
这样就可以点击自组建的按钮,调用父组件的方法

浙公网安备 33010602011771号