【问题标题】:Laravel/Slick: Uncaught TypeError: $(...).slick is not a functionLaravel/Slick:未捕获的 TypeError:$(...).slick 不是函数
【发布时间】:2021-04-08 09:55:51
【问题描述】:

我正在尝试使用 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)

【问题讨论】:

  • 似乎slick.min.js 根本没有被加载。您是否检查过浏览器的开发工具网络选项卡?
  • slick.min.js 根据我的浏览器的开发工具在 jquery 文件之后正确加载。似乎所有内容都已正确加载。
  • 然后是slick.min.js在文档准备好后加载的情况。将所有脚本标签移动到文档的&lt;head&gt;
  • 当我将所有脚本标签放在&lt;head&gt; 中时,我仍然收到同样的错误。当我给出整个错误消息时,它可能会有所帮助吗?我已经用整个错误消息更新了帖子

标签: javascript html laravel slick.js


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2019-05-24
    • 2021-10-23
    • 1970-01-01
    • 2015-08-27
    • 1970-01-01
    • 2017-05-15
    • 2020-04-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多