C#告诉我:
无法解析符号‘InvokeAsync’
在下面的await this.onClick.InvokeAsync(this.targetPerson);
行代码中:
public partial class PersonCard : Microsoft.AspNetCore.Components.ComponentBase
{
[Microsoft.AspNetCore.Components.Parameter]
public required CommonSolution.Entities.Person targetPerson { get; set; }
[Microsoft.AspNetCore.Components.Parameter]
public Microsoft.AspNetCore.Components.EventCallback<CommonSolution.Entities.Person>? onClick { get; set; } = null;
[Microsoft.AspNetCore.Components.Parameter]
public string rootElementTag { get; set; } = "div";
[Microsoft.AspNetCore.Components.Parameter]
public string? spaceSeparatedAdditionalCSS_Classes { get; set; } = null;
private async System.Threading.Tasks.Task onClickOutermostElement()
{
if (this.onClick is null)
{
return;
}
await this.onClick.InvokeAsync(this.targetPerson);
}
}
如果使onClick
不可为空并删除空判断,则编译将起作用.
我做错了什么?