Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

how use a javascript file on specific page in blazor static server side rendering

$
0
0

i tried to use java script in blazor static server side rendering

first try to use a section outlet in layout and a section content in page , but a problem occurred

let's say i have a home page , and have a homepage.js file , i reference it as following

<SectionContent SectionName="pagescripts"><script src="./homepage.js" ></script></SectionContent> 

my code run very well , but when navigate to another page let's call it weather and come back to home page , my script not worked anymore !

try to solve my problem and google it , then find bellow link
https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/static-server-rendering?view=aspnetcore-8.0

but when read it , it's seem like it's incomplete , like where to add wwwroot/BlazorPageScript.lib.module.js
or what it is page-script , where it is defined or how define it

<page-script src="@Src"></page-script>

and what mean we add a query string each time to js file on bellow code

<PageScript Src="./Components/Pages/PageWithScript.razor.js?counter" />

expected to easily use javascript like usual add a js file on a page , like using in asp.net core razor pages , if js changed , send a request to get new file , otherwise use the cached file , we use asp-append-version= true on asp.net core razor pages , i dont know how do it in blazor


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>