admin管理员组文章数量:1334886
I'm trying to integrate Stripe payments to my Blazor application. Straight away as predicted I must have a <script>
tag on my page.
My question is, how do I add this script tag to a Razor page in Blazor. I've used interop to define my own JS files and call their methods, but i need this script to just be added to the DOM.
This documentation only shows me how to connect to my own JavsScript files:
.0#javascript-isolation-in-javascript-modules
I'm trying to integrate Stripe payments to my Blazor application. Straight away as predicted I must have a <script>
tag on my page.
https://stripe./docs/billing/quickstart
My question is, how do I add this script tag to a Razor page in Blazor. I've used interop to define my own JS files and call their methods, but i need this script to just be added to the DOM.
This documentation only shows me how to connect to my own JavsScript files:
https://learn.microsoft./en-us/aspnet/core/blazor/javascript-interoperability/call-javascript-from-dotnet?view=aspnetcore-6.0#javascript-isolation-in-javascript-modules
Share Improve this question asked Oct 22, 2022 at 17:49 JsonStathamJsonStatham 10.4k28 gold badges111 silver badges189 bronze badges 1- Does this answer your question? Blazor Server: load js scripts only on certain pages, not on all – Dimitris Maragkos Commented Oct 22, 2022 at 18:44
2 Answers
Reset to default 3you can use new feature of blazor wasm and Use JSExportAttribute and JSImportAttribute and Handle your js modules in also you can read documentation here
Edited 2023-10-10
in .NET 8 you can add external JS files in your razor ponents and pages with <script>
tag and piler no longer given error to using that
Continuing answer of Sajjad Arash At the bottom of the page add:
<script src="../Components/Pages/Component.razor.js"></script>
本文标签: javascriptHow do I add an external JS Script to a Blazor pageStack Overflow
版权声明:本文标题:javascript - How do I add an external JS Script to a Blazor page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742371108a2462256.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论