I couldn't find anything that would allow me to run js code in blazor without having to call a function from a js file and I'm wondering if it is possible, since it would be much easier to just write some js in my blazor component.
Something like this:
@inject IJSRuntime JSRuntime
@code {
protected override void OnInitialized()
{
JSRuntime.InvokeVoidAsync(
{
// Write JS in here, like this:
console.log("i possible hope this is");
});
StateHasChanged();
}
}
Is something like the example above a possibility?
you have to call a function but can work around as eval is a function takes JS code used it to inject JS from library projects https://blog.ppedv.de/post/Razor-Classlibrary-JavaScript-einbinden
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With