简体   繁体   English

$不是flexslider中的函数

[英]$ not a function in flexslider

I want to stop autoslider in flexslider module.I caught 我想在flexslider模块中停止autoslider。

undefined TypeError:$ is not a function 未定义的TypeError:$不是函数

jQuery(window).load(function($) {
    $('#testvideo').flexslider({ //undefined TypeError:$ is not a function
        slideshow: false
    });
});

How to fix the error 如何解决错误

The reference to jQuery - the $ function in this case - is not passed as a parameter. 对jQuery的引用-在这种情况下为$函数-不会作为参数传递。 The function gets the event object instead. 该函数改为获取事件对象。 By specifying it in the parameters list, you're overwriting it. 通过在参数列表中指定它,可以覆盖它。 There are multiple avenues to fix this. 有多种解决方法。

If you're not using noConflict , it can be easily fixed by removing $ from the function's definition: jQuery(window).load(function() { . If you do, then you can either use jQuery() instead of $ as such 如果您不使用noConflict ,则可以通过从函数的定义中删除$来轻松解决: jQuery(window).load(function() { 。如果这样做,则可以使用jQuery()代替$这样

jQuery(window).load(function(event) {
jQuery('#testvideo').flexslider({ //undefined TypeError:$ is not a function
   slideshow: false
 });
});

or wrap everything in a IIFE: 或将所有内容包装在IIFE中:

(function($) {
    $(window).load(function() {
    $('#testvideo').flexslider({ //undefined TypeError:$ is not a function
       slideshow: false
     });
    });
})(window.jQuery);

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

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