Cant import scoped Javascript in Blazor Standalone WebAssembly
In the past I have already done this in InteractiveServer Blazor, which is to import
{page}.razor.js
in my razor page through IJSRuntime
in the OnAfterRender
step of the page lifecycle. as follows:
Page.Razor.cs
Page.razor.js
There is a way to make something similar work, by using global javascript files in wwwroot\*.js
and <script...
directives but that is not desired in the moment. I didn't find any way to use a modular aproach handled by the ComponentBase
object.
This is the web assembly startup implementation
Program.cs
.NET Core 9 environment// stack overflow post: https://stackoverflow.com/questions/79542079/cant-import-scoped-javascript-in-blazor-standalone-webassembly
Stack Overflow
Cant import scoped Javascript in Blazor Standalone WebAssembly
In the past I have already done this in InteractiveServer Blazor, which is to import {page}.razor.js in my razor page through IJSRuntime in the OnAfterRender step of the page lifecycle. as follows:...
1 Reply
Just for clarification, theInvokeAsync
instruction will FAIL due to not being able to find thePage.razor.js
file I Just found out the solution for this. The import path must be preceded with "../" in order to get out of thewwwroot
folder, although I don't know how it goes for production scenarios.