打开新电路后,我无法调用 JSInterop 方法。我正在通过从 JS 中打开一个新选项卡来创建新电路,如下所示:
await _jsRuntime.InvokeAsync<object>("open", "/new-tab", "_blank");
接下来,在新选项卡中呈现的组件中,我尝试调用这样的 JS 方法:
protected override async Task OnAfterRenderAsync(bool firstRender) {
if (firstRender)
await jsRuntime.InvokeVoidAsync("myJSmethod");
}
一旦调用 jsRuntime,我就会收到以下错误:
The connection to ws://localhost:53216/myapp/ was interrupted while the page was loading.
dotnet-watch reload socket error.
> error { target: WebSocket, isTrusted: true, srcElement: WebSocket, currentTarget: WebSocket, eventPhase: 2, bubbles: false, cancelable: false, returnValue: true, defaultPrevented: false,
composed: false, ... }
dotnet-watch reload socket closed.
任何帮助或建议表示赞赏!