首页 > 解决方案 > Laravel/Slick:未捕获的 TypeError:$(...).slick 不是函数

问题描述

我正在尝试使用 Slick 在我的 Laravel 网站上放置一些推荐。我已按照此说明创建推荐信:https ://codepen.io/mark_sottek/pen/mJdByp

如上所述添加所有脚本时,我总是收到错误“Uncaught TypeError: $(...).slick is not a function”。

我已经尝试了在这里找到的几种解决方案,但没有一个对我有用。

我的代码:

<section class="quotes">
    <div class="bubble">
        <blockquote>I refuse to accept the view that mankind is so tragically bound to the starless midnight of racism and war that the bright daybreak of peace and brotherhood can never become a reality... I believe that unarmed truth and unconditional love will have the final word.</blockquote>
        <div></div>
        <cite> Martin Luther King, Jr.</cite>
    </div>
    <div class="bubble">
        <blockquote> Peace is not a relationship of nations. It is a condition of mind brought about by a serenity of soul. Peace is not merely the absence of war. It is also a state of mind. Lasting peace can come only to peaceful people.</blockquote>
        <div></div>
        <cite> Jawaharlal Nehru</cite>
    </div>
    <div class="bubble">
        <blockquote> Forgiveness is not always easy. At times, it feels more painful than the wound we suffered, to forgive the one that inflicted it. And yet, there is no peace without forgiveness.</blockquote>
        <div></div>
        <cite> Marianne Williamson</cite>
    </div>
    <div class="bubble">
        <blockquote>Of all our dreams today there is none more important - or so hard to realise - than that of peace in the world. May we never lose our faith in it or our resolve to do everything that can be done to convert it one day into reality. </blockquote>
        <div></div>
        <cite> Lester B. Pearson</cite>
    </div>
</section>

<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="{{ asset('slick/slick.min.js') }}"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $('.quotes').slick({
            dots: true,
            infinite: true,
            autoplay: true,
            autoplaySpeed: 6000,
            speed: 800,
            slidesToShow: 2,
            adaptiveHeight: true
        });
    });
</script>

感谢您的任何帮助。

更新:整个错误消息:

Uncaught TypeError: $(...).slick is not a function
    at HTMLDocument.<anonymous> ((index):19)
    at j (jquery-1.11.0.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-1.11.0.min.js:2)
    at Function.ready (jquery-1.11.0.min.js:2)
    at HTMLDocument.K (jquery-1.11.0.min.js:2)

标签: javascripthtmllaravelslick.js

解决方案


将 jquery-1.11.0.min.js 文件更新为更新版本的 jquery。这将解决错误。


推荐阅读