未捕获的TypeError:$(...).owlCarousel不是函数

编程入门 行业动态 更新时间:2024-10-27 21:15:32
本文介绍了未捕获的TypeError:$(...).owlCarousel不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已将owlCarousel添加到我的页面.但我收到此错误.并坚持了几个小时..:(

I have added owlCarousel to my page. but im getting this error. and stuck with it hours.. :(

HTML代码

custom.js中的功能 $(#owl-hero").owlCarousel({

function in custom.js $("#owl-hero").owlCarousel({

navigation: true, // Show next and prev buttons slideSpeed: 300, paginationSpeed: 400, singleItem: true, transitionStyle: "fadeUp", autoPlay: true, navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"] });

添加了参考

Chrome的屏幕截图

推荐答案

如果脚本乱序,则会出现此错误.您必须以正确的顺序加载

You will get this error if your scripts are out of order. You must load in the right order

  • jquery

  • jquery

    您喜欢的旋转木马(猫头鹰旋转木马)

    your fancy carousel (owl carousel)

    您的脚本调用owlCarousel()

    (如果您从未首先导入owlCarousel插件,也将获得此提示.)

    (You will also get this if you never imported the owlCarousel plugin in the first place.)

    说明:jquery将$变量放在全局名称空间中.您的owlCarousel插件将修改全局名称空间.然后,您可以在jquery中将其称为可链接函数.它必须按此顺序发生,如果缺少或重新排列,它将损坏.

    To explain: jquery will put the $ variable in the global namespace. your owlCarousel plugin will modify the global namespace. Then you may call it as a chainable function in jquery. It must occur in this order, if anything is missing or rearranged it shall break.

    要解决:移动jQuery

    To fix: Move jQuery

    <script src="ajax.googleapis/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

    在整个已加载脚本系列的顶部.当前会在所有需要它的插件之后 加载它.

    to the top of the entire series of loaded scripts. It is currently loaded after all of the plugins that need it.

    以下是猫头鹰轮播"文档中的更多详细信息:

    Here is more detail from the Owl Carousel docs:

    <!-- Important Owl stylesheet --> <link rel="stylesheet" href="owl-carousel/owl.carousel.css"> <!-- Default Theme --> <link rel="stylesheet" href="owl-carousel/owl.theme.css"> <!-- jQuery 1.7+ --> <script src="jquery-1.9.1.min.js"></script> <!-- Include js plugin --> <script src="assets/owl-carousel/owl.carousel.js"></script>

    您必须按照该顺序导入资产.请参阅: owlgraphic/owlcarousel/

    You must import assets in that order. See: owlgraphic/owlcarousel/

    还要在您的代码中.确保在$(document).ready上调用轮播,以便所有脚本和DOM都已初始化.

    Also in your code..make sure you call the carousel on $(document).ready, so all your scripts and the DOM are initialized.

    $(document).ready(function() { $("#owl-hero").owlCarousel({ navigation: true, // Show next and prev buttons slideSpeed: 300, paginationSpeed: 400, singleItem: true, transitionStyle: "fadeUp", autoPlay: true, navigationText: [ "<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>" ] }); });
  • 更多推荐

    未捕获的TypeError:$(...).owlCarousel不是函数

    本文发布于:2023-11-23 03:46:18,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1619972.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:函数   TypeError   owlCarousel

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!