❔ Blazor Server .net7 js injection

Hey, i'm currently leaning blazor, i've seen that js can be isolated as css file but i have to do
@code
{
private IJSObjectReference module;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
Console.WriteLine("index");
module = await JS.InvokeAsync<IJSObjectReference>("import", "./Pages/Index.razor.js");
}
}
@code
{
private IJSObjectReference module;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
Console.WriteLine("index");
module = await JS.InvokeAsync<IJSObjectReference>("import", "./Pages/Index.razor.js");
}
}
so that mean for every component that i want to use i need to redo that. I see the way to use an @inherit and doing a generic class to do that but i want to figure out if maybe there is a better way to "inject" js when ther eis a component.razor.js file available
1 Reply
Accord
Accord14mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server