Cant find MouseEventArgs

心不动则不痛 提交于 2019-12-11 06:38:42

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!