繁体   English   中英

WordPress jQuery问题,未捕获ReferenceError:jQuery未定义

[英]WordPress jQuery issue, Uncaught ReferenceError: jQuery is not defined

我一直在搜索stackoverflow和Google,但仍未解决此问题。 它说Uncaught ReferenceError:jQuery未定义

jQuery已在页眉中,而slipper.min js已在页脚中。 不知道该怎么办。

这是网站,您可以在这里检查。 https://ig.design/sliderfix/wordpress/shop/loft/

你能让我知道是什么问题吗?

谢谢

WordPress可以安全地将jQuery保留在window.jQuery对象中(而不是$

明确告诉wp使用$或将代码包装在闭包中

;(function($){
    // in here $ points to jQuery and does not pollute the global scope

)(jQuery);

您已经在标题中连接了slippry.min.js,下面是jQuery。 (您可以查看看到此问题的页面的源)

在functions.php中用于在jquery之后连接页脚中的滑动:

wp_enqueue_script( 'slippry', 'https://cdnjs.cloudflare.com/ajax/libs/slippry/1.4.0/slippry.min.js', array( 'jquery' ), null, true );

更新:您还在页脚和页眉中两次连接了slippry.min.js。

连接jquery和slippry.min.js后,还需要添加一个函数来调用滑块

(function(){
    $('selector').slippry();
}());

暂无
暂无

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

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