找不到类型或名称空间IJSObjectReference [英] The type or namespace IJSObjectReference could not be found
问题描述
我刚开始玩Blazor.我正在尝试从剃刀局部类中调用javascript函数.
I just started Blazor. I am trying to invoke a javascript function from a razor partial class.
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");
}
}
我收到以下错误找不到类型或名称空间IJSObjectReference
.也没有选择将软件包安装在intellisense中,也假定它是缺少的软件包问题.我已经搜索过但没有看到任何相关信息.我认为这个问题与.NET 5版本有关,或者也许我需要安装一个软件包.
I get the following error The type or namespace IJSObjectReference could not be found
. There is no option to install the package in intellisense too assuming it's a missing package issue. I have searched but haven't seen anything related. I am thinking this issue has something to do with the .NET 5 release or maybe there is a package I need to install.
推荐答案
IJSObjectReference
仅适用于.NET5.因此,使用.NET 5创建项目可解决此问题.
IJSObjectReference
is only available with the .NET 5. So, creating the project with .NET 5 fixed the issue.
这篇关于找不到类型或名称空间IJSObjectReference的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!