我刚开始工作。我正在尝试从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。在intellisense中也没有安装包的选项,假设这是一个缺少包的问题。我已经搜索过了,但没有看到任何相关的东西。我认为这个问题与.NET 5版本有关,或者可能有我需要安装的包。
发布于 2020-12-05 11:19:50
IJSObjectReference仅在.NET 5中可用,因此,使用.NET 5创建项目解决了此问题。
https://stackoverflow.com/questions/65064483
复制相似问题