问题
I have been following along with Create and use ASP.NET Core Razor components
I am having an issue with this section
<div class="panel panel-default">
<div class="panel-heading">@Title</div>
<div class="panel-body">@ChildContent</div>
<button class="btn btn-primary" @onclick="OnClick">
Trigger a Parent component method
</button>
</div>
@code {
[Parameter]
public string Title { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
[Parameter]
public EventCallback<MouseEventArgs> OnClick { get; set; }
}
I keep getting the following error
Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'MouseEventArgs' could not be found (are you missing a using directive or an assembly reference?) BlazorList D:\Development\BlazorApp1\BlazorList\Pages\ShowListComponent.razor 19 Active
回答1:
The event names have been changed in Preview 9
from the blog (https://devblogs.microsoft.com/aspnet/asp-net-core-and-blazor-updates-in-net-core-3-0-preview-9/):
Replace Microsoft.AspNetCore.Components.UIEventArgs with System.EventArgs and remove the “UI” prefix from all EventArgs derived types (UIChangeEventArgs -> ChangeEventArgs, etc.).
So preview 8 and below need the UI prefix on the event name and the Microsoft.AspNetCore.Components.UIEventArgs namespace.
preview 9 does not need the UI prefix on the event name. and requires the namespace System.EventArgs
来源:https://stackoverflow.com/questions/57892515/cant-find-mouseeventargs