Blazor & Javascript
-
Front-End
Blazor----------------------
<button onclick="Handle()">Click</button>
@using Microsoft.JSInterop
@inject IJSRuntime JS
@code {
protected async Task HandleClick()
{
await JS.InvokeVoidAsync("Handle");
}
}
Javascript----------------------(inside wwwroot)
function Handle() {
console.log("Navbar toggle!");
}
call in index.html--------------------
<script src="script.js"></script>