Javascript interop/not linking as I would expect
I understand that I may be doing this wrong, but with the knowledge I have this is confusing and I am hoping someone can clear this up for me, as I am trying to understand how I can link javascript files that are already functioning with my app components.
https://github.com/InnovationGB/BlazorRainEffect
This isn't anything I made but rather a project from 2015 utilizing webgl in order to give a rainy effect. I moved all my resources into my wwwroot folder, (index.html,css/images/js) and within my index.html i remove blazor boot script and
But if I take the body contents from index.html, and slap it into my mainlayout.cshtml, when I load my index.cshtml component/page I get a console error
Uncaught (in promise) TypeError: Cannot set property 'width' of null
at s (index.min.js:7)
I tried reading into https://learn-blazor.com/architecture/interop/ but there are A LOT of functions that I would have to recreate functions for. Is what I am trying to do impossible/or am I missing a very key fundamental aspect to this situation? Sorry for the nooby question. Blazor just really interests me and is a lot less confusing than MVC theres just kind of a lack of areas for me to go in order to receive help (Stack over flow tells me that my situation is not related to blazor no matter what the case)
Thanks, p.s. Im kind of new to github so Im not sure if this is an appropriate issue to even post here.
I tried changing the properties in my js folder to embedded resource rather than content and still no luck.
Depends on what you want to do exactly. The blazor-boot element will be replaced to contain the boot code of blazor while the <app> element will contain the rendered output of the page and layout matching the route. For each method you'd like to call from C#, you need to Blazor.registerFunction it and for just rendering html to the page you write razor markup.
I recommend you watch @SteveSandersonMS talk on NDC which introduce you to Blazor properly and show almost everything you need to know to use it including how to properly interop with JS/TS by using the Blazor Library projects.
https://www.youtube.com/watch?v=JU-6pAxqAa4
@InnovationGB I hope the video that @galvesribeiro pointed you to has helped.
I'm not sure what additional help to give here because I can't quite tell what you're trying to do. Maybe your problem is resolved by watching the video. If not, please try to give us more info, perhaps by reducing your problem to something as small as "here's a snippet of JS code I want to use, where should I put it?" (for which the answer would be "in a .js file that you reference from a <script> tag in your index.html, and then write a Blazor.registerFunction call to make it available to .NET code).