我一直在搜索stackoverflow和Google,但仍然没有解决这个问题。它说Uncaught ReferenceError:jQuery未定义
jquery已经在页眉中,而slipper.min js在页脚中。不知道该怎么办。
这是网站,您可以在这里检查。 https://ig.design/sliderfix/wordpress/shop/loft/
能否让我知道问题出在哪里?
谢谢
答案 0 :(得分:1)
Wordpress安全运行,并将jQuery保留在window.jQuery
对象(而不是$
)中
明确告诉wp使用$或将代码包装在闭包中
;(function($){
// in here $ points to jQuery and does not pollute the global scope
)(jQuery);
答案 1 :(得分:1)
您已经在标题中连接了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();
}());