JavaScript 代码:
window.myInterop = {
helloWorld: function () {
console.log('Hello world from JavaScript');
}
};
C# 代码:
@using System.Runtime.InteropServices
@inject IJSRuntime JSRuntime
@code {
[DllImport("myLibrary.js")]
public static extern void helloWorld();
async Task CallJavaScript()
{
await JSRuntime.InvokeAsync