jQuery $(...).flexslider 不是函数错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18148460/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 21:07:24  来源:igfitidea点击:

$(...).flexslider is not a function error

jqueryflexsliderjoomla3.0

提问by user2668042

I'm developing a Joomla 3 template using the T3 Framework and I've included an IceCarouselmodule which uses the Flexsliderplugin. However, the IceCarouselmodule isn't working because there is a javascript error that says:

我正在使用 T3 框架开发 Joomla 3 模板,并且我已经包含了一个IceCarousel使用该Flexslider插件的模块。但是,该IceCarousel模块无法正常工作,因为有一个 javascript 错误显示:

$(...).flexslider is not a function
Line 477

I've taken a look at the page source and the flexslider source files are definitely there. There is also a /media/jui/jquery-noconflict.jsfile which comes standard with Joomla 3. I am not sure if this is what is causing the problem. Is this an issue of the order of the stacking of the javascript files?

我查看了页面源代码,flexslider 源文件肯定在那里。/media/jui/jquery-noconflict.jsJoomla 3也有一个标准文件。我不确定这是否是导致问题的原因。这是javascript文件堆叠顺序的问题吗?

http://www.veterantrainingsymposium.com/2014-home-page

http://www.veterantrainingsymposium.com/2014-home-page

回答by Mangesh Parte

You have defined the jquery two times. remove one jquery http://gyazo.com/c784a654eefe6e1b6ac061e562f3f051

您已经定义了两次 jquery。删除一个 jquery http://gyazo.com/c784a654eefe6e1b6ac061e562f3f051

回答by Amit

I was faced the same problem and fixed it. I have used only one instance of jquery.js file, but still was getting the same problem.

我遇到了同样的问题并修复了它。我只使用了 jquery.js 文件的一个实例,但仍然遇到同样的问题。

After self investigating finally I got the issue and fix it,keep in mind do not use defer or async keyword in below 2 files:

经过自我调查最终我发现了问题并修复了它,请记住不要在以下 2 个文件中使用 defer 或 async 关键字:

1- jquery.flexslider-min.js

1- jquery.flexslider-min.js

2- jquery.prettyPhoto.js

2- jquery.prettyPhoto.js

回答by Hyman Robson

I was using a WordPress plugin (Meta-Slider) and it did not include the Jquery Flexslider module.

我使用的是 WordPress 插件 (Meta-Slider),但它不包含 Jquery Flexslider 模块。

Downloaded from here: https://github.com/woocommerce/FlexSlider

从这里下载:https: //github.com/woocommerce/FlexSlider

Added to my project, added to my header after a normal Jquery...

添加到我的项目中,在普通 Jquery 之后添加到我的标题中...

    <script src="<?php echo get_bloginfo('template_directory'); ?>/js/jquery-3.2.1.min.js"></script>
    <script src="<?php echo get_bloginfo('template_directory'); ?>/js/jquery.flexslider-min.js"></script>

Then got rid of some other buggy JS code that came after and it's working.

然后摆脱了之后出现的其他一些有问题的 JS 代码并且它正在工作。

回答by Kablooey Monster

For people using Wordpress and getting this error:

对于使用 Wordpress 并收到此错误的人:

Make sure that the link to the FlexSlider js ( ie: <script defer src="<?php bloginfo('template_url'); ?>/js/jquery.flexslider-min.js"></script>) is below <?php wp_head(); ?>

确保 FlexSlider js(即:)的链接在<script defer src="<?php bloginfo('template_url'); ?>/js/jquery.flexslider-min.js"></script>下面<?php wp_head(); ?>

This is applicable to loading script in the header.php file. Better practice would be to load all js in the footer, but there may be instances when you don't have control over that.

这适用于在header.php 文件中加载脚本。更好的做法是在页脚中加载所有 js,但可能存在您无法控制的情况。

Hope this helps someone else as it helped me :)

希望这能帮助其他人,因为它帮助了我:)

回答by Peter

Try simplifying your code to test if there is a timing issue, e.g.:

尝试简化代码以测试是否存在计时问题,例如:

$(document).ready(function() {
$('#icecarousel119').flexslider({
    selector: ".slides > div", 
    animation: "slide",
    direction: "horizontal",
    itemWidth:90,
    slideshowSpeed:5000, 
    animationspeed:600,  
    itemMargin:0,
    minItems:1,
    maxItems:0, 
    move: 0,    

            slideshow: false,

            directionNav: true,

            controlNav: true,

    start: function(slider){
      $('body').removeClass('loading');
    }
  });
});

});

});

Also, flexslider examples use class, not id (though I don't think this is causing the issue)

此外,flexslider 示例使用类,而不是 id(虽然我不认为这是导致问题的原因)