我刚开始学习Blazor。我正在尝试从Razor部分类中调用一个javascript函数。
using Microsoft.JSInterop;
public partial class Counter
{
[Inject] IJSRuntime js { get; set; }
IJSObjectReference module;
[JSInvokable]
public async Task IncrementCount()
{
module = await js.InvokeAsync<IJSObjectReference>("import", "./js/Counter.js");
await module.InvokeVoidAsync("displayAlert", "New message");
}
}
我遇到了以下错误:The type or namespace IJSObjectReference could not be found
。在智能感知中没有安装该包的选项,因此我认为这可能是一个缺失的包问题。我已经搜索过,但没有看到任何相关的内容。我认为这个问题与.NET 5发布有关,或者可能需要安装某个包。