简体   繁体   English

如何在特定的 blazor 页面中调用 javascript 代码

[英]how call a javascript code in a specific blazor page

Im converting a website in blazor, i have a page where at the end ther's this javascript我在 blazor 中转换一个网站,我有一个页面,最后是这个 javascript

(function ($) {
    "use strict";
    $(document).ready(function () {
        $('#slider-range').slider({
          ..... more

How can i call it in blazor?我如何在 blazor 中调用它? I did not find a solution that works我没有找到可行的解决方案

Thanx谢谢

Yes it can work, the problem is blazor does not understand $ jquery selector, you need to replace it with document in .js script for it to work.是的,它可以工作,问题是 blazor 不理解$ jquery 选择器,你需要用.js脚本中的document替换它才能工作。 for example, change $('#slider-range').slider({ to document.getElementById('#slider-range').slider({ then this line will work and same for everyplace where $ is present. And just remove it from function definition like this (function () {例如,将$('#slider-range').slider({更改为document.getElementById('#slider-range').slider({然后这条线将适用于存在$的每个地方。然后删除它来自这样的函数定义(function () {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM