Slick Carousel Uncaught TypeError:$(...)。slick不是一个函数 [英] Slick Carousel Uncaught TypeError: $(...).slick is not a function

查看:177
本文介绍了Slick Carousel Uncaught TypeError:$(...)。slick不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知何故,我无法正确使用光滑的旋转木马( http://kenwheeler.github.io/slick/ ) 。

Somehow I'm unable to use slick carousel (http://kenwheeler.github.io/slick/) correctly.

我收到以下错误:

Uncaught TypeError: $(...).slick is not a function

我正在运行以下代码javascript文件:

I'm running the following code in my javascript file:

function initSlider(){
    $('.references').slick({
        dots: false,
        infinite: true,
        speed: 300,
        slidesToShow: 1,
        autoplay: true,
        prevArrow: '<div class="slick-prev"><i class="fa fa-chevron-left"></i></div>',
        nextArrow: '<div class="slick-next"><i class="fa fa-chevron-right"></i></div>'
    });
}

我已经包含了最新的jQuery版本(2.1.4)和bower。我也尝试将jQuery CDN包含在我的布局模板文件的头部,但这也没有解决任何问题。

I've included the latest jQuery version (2.1.4) with bower. I've also tried including the jQuery CDN in the head of my layout template file, but that didn't resolve anything either.

唯一可能意味着什么奇怪的东西是当我不使用函数来调用滑块时,它确实有效,但它给了我错误:

The only thing strange that could mean something is that when I don't use a function to call the slider, it does work but it gives me the error:

Uncaught TypeError: Cannot read property 'add' of null

我发现这意味着代码已被删除在加载DOM之前加载,这是正确的(我认为)。

I found out that that means that the code has been loaded before the DOM was loaded, which is correct (I think).

提前致谢!

编辑:我从我的代码中创建了一个JSFiddle: https://jsfiddle.net/brz30e77/

I've created a JSFiddle from my code: https://jsfiddle.net/brz30e77/

EDIT2:在我的JS文件中添加新函数时,错误一直存在。我最终剥离了我的串联JS文件,发现有两个版本的jQuery被加载,其中一个非常非常老。

The error persisted every now and then when adding new function to my JS file. I ultimately stripped my concatenated JS file and found out that there were two versions of jQuery being loaded, of which one was very, very old.

推荐答案

我后来自己找到了解决方案,所以我把它作为答案:

I found the solution myself later, so I placed it as an answer:

在我的JS文件中添加新函数时,错误一直存在。我最终剥离了我的串联JS文件,发现有两个版本的jQuery被加载,其中一个非常非常老。

The error persisted every now and then when adding new function to my JS file. I ultimately stripped down my concatenated JS file and found out that there were two versions of jQuery being loaded, of which one was very, very old.

这篇关于Slick Carousel Uncaught TypeError:$(...)。slick不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆