C# Blazor子组件EventCallBack未响应

C# Blazor子组件EventCallBack未响应,c#,components,blazor,blazor-server-side,blazor-client-side,C#,Components,Blazor,Blazor Server Side,Blazor Client Side,这里是页面组件 @page "/student" <h3>Student List</h3> <h5>@StudentsList</h5> <StudentDetail StudentName="Something New" ButtonClicked="@Save"></StudentDetail> <h5>This is second</h

这里是页面组件

@page "/student"
<h3>Student List</h3>
<h5>@StudentsList</h5>

<StudentDetail StudentName="Something New" ButtonClicked="@Save"></StudentDetail>

<h5>This is second</h5>
<h5>@SaveMessage</h5>


@code {
    public string StudentsList { get; set; }
    private string SaveMessage { get; set; }

    protected override async Task OnInitializedAsync()
    {
        StudentsList = "ASD DSA KDS CFA";
    }

    private void Save(MouseEventArgs e)
    {
        SaveMessage = "Operation Saved.";
    }
}
学生详情:

它是
@onclick
,而不是
@onclick
中的
@onclick=“ButtonClicked”

当您单击
“单击我!”
按钮时,您实际上想要触发Student组件中的“Save”方法。这就是你如何做到的:

`@onclick="() => ButtonClicked.InvokeAsync()"`
学生:
ButtonClicked=“@Save”
更改为
ButtonClicked=“Save”

无效。甚至可以尝试调用异步方法,如;点击我@代码{[Parameter]公共字符串StudentName{get;set;}[Parameter]公共事件回调按钮点击{get;set;}公共异步void ExecuteAsync(MouseevenTargets e){Wait ButtonClicked.InvokeAsync(e);}}仍然不起作用..再次说明:它是@onclick,不是@onclick。你看到区别了吗。不要使用异步void,请使用异步任务
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop
@using BlazorApp4
@using BlazorApp4.Shared
`@onclick="() => ButtonClicked.InvokeAsync()"`