【问题标题】:How do I add a reference to a Blazor page?如何添加对 Blazor 页面的引用?
【发布时间】:2020-01-19 16:14:09
【问题描述】:

我的 razor 页面缺少 UIMouseEventArgs 参数对 Microsoft.AspNetCore.Components.Web 的引用。我在哪里添加参考? IE。我该如何解决这个问题?

这是剃须刀页面代码:

@page "/counter"

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
    int currentCount = 0;

    [Parameter] public String incSzTxt { get; set; } = "1";

    void IncrementCount(UIMouseEventArgs e)
    {
        currentCount += int.Parse(incSzTxt);
    }
}

【问题讨论】:

    标签: asp.net-core razor-pages blazor


    【解决方案1】:

    我的 razor 页面缺少 UIMouseEventArgs 参数对 Microsoft.AspNetCore.Components.Web 的引用。

    不,在 Blazor 的 latest edition (>= Preview9) 中,UIMouseEventArgs 现在称为 MouseEventArgs。但我认为您根本不应该在 Button.Click 处理程序中使用它们。

      //void IncrementCount(UIMouseEventArgs e)
        void IncrementCount()
        {
            currentCount += int.Parse(incSzTxt);
        }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-16
    • 2022-10-24
    • 2021-01-07
    • 2017-07-26
    • 1970-01-01
    • 2021-09-13
    • 1970-01-01
    • 2014-05-15
    相关资源
    最近更新 更多