简体   繁体   English

Jquery bxslider异常

[英]Jquery bxslider exception

Alright so the problem is basically unknown for me, never had it before. 好吧所以问题对我来说基本上是未知的,从来没有过。 I tried adding bxslider today but it seems it doesnt work properly. 我今天尝试添加bxslider,但它似乎无法正常工作。 I tried using the other version of the JS that he provided but same thing happends, the images keep on "loading" and they never load. 我尝试使用他提供的其他版本的JS,但同样的事情发生,图像继续“加载”,他们永远不会加载。 I did inspect element and this is what I got 我做了检查元素,这就是我得到的

jQuery.Deferred exception: Cannot read property 'indexOf' of undefined TypeError: Cannot read property 'indexOf' of undefined at jQuery.fn.load (file:///C:/Users/Oploditelj/Desktop/domaci_last/js/jquery-3.0.0.js:9612:12) at HTMLImageElement. jQuery.Deferred异常:无法读取未定义的属性'indexOf'TypeError:无法在jQuery.fn.load中读取未定义的属性'indexOf'(file:/// C:/ Users / Oploditelj / Desktop / domaci_last / js / jquery- 3.0.0.js:9612:12)在HTMLImageElement。 (file:///C:/Users/Oploditelj/Desktop/domaci_last/js/plugin/jquery.bxslider.min.js:10:4394) at Function.each (file:///C:/Users/Oploditelj/Desktop/domaci_last/js/jquery-3.0.0.js:359:19) at jQuery.each (file:///C:/Users/Oploditelj/Desktop/domaci_last/js/jquery-3.0.0.js:152:17) at HTMLImageElement. (file:/// C:/Users/Oploditelj/Desktop/domaci_last/js/plugin/jquery.bxslider.min.js:10:4394)在Function.each(file:/// C:/ Users / Oploditelj / Desktop / domaci_last / js / jquery-3.0.0.js:359:19)at jQuery.each(file:/// C:/Users/Oploditelj/Desktop/domaci_last/js/jquery-3.0.0.js:152 :17)在HTMLImageElement。 (file:///C:/Users/Oploditelj/Desktop/domaci_last/js/plugin/jquery.bxslider.min.js:10:4355) at Function.each (file:///C:/Users/Oploditelj/Desktop/domaci_last/js/jquery-3.0.0.js:359:19) at jQuery.each (file:///C:/Users/Oploditelj/Desktop/domaci_last/js/jquery-3.0.0.js:152:17) at g (file:///C:/Users/Oploditelj/Desktop/domaci_last/js/plugin/jquery.bxslider.min.js:10:4295) at c (file:///C:/Users/Oploditelj/Desktop/domaci_last/js/plugin/jquery.bxslider.min.js:10:4180) at d (file:///C:/Users/Oploditelj/Desktop/domaci_last/js/plugin/jquery.bxslider.min.js:10:2570) undefined (file:/// C:/Users/Oploditelj/Desktop/domaci_last/js/plugin/jquery.bxslider.min.js:10:4355)在Function.each(file:/// C:/ Users / Oploditelj / Desktop / domaci_last / js / jquery-3.0.0.js:359:19)at jQuery.each(file:/// C:/Users/Oploditelj/Desktop/domaci_last/js/jquery-3.0.0.js:152 :17)at g(file:/// C:/Users/Oploditelj/Desktop/domaci_last/js/plugin/jquery.bxslider.min.js:10:4295)at c(file:/// C:/ Users /Oploditelj/Desktop/domaci_last/js/plugin/jquery.bxslider.min.js:10:4180)在d(file:/// C:/Users/Oploditelj/Desktop/domaci_last/js/plugin/jquery.bxslider。 min.js:10:2570)未定义

The code that Im using is exactly the same as the one that was on their website. 我使用的代码与他们网站上的代码完全相同。

<head> 
        <script type="text/javascript" src="js/jquery-3.0.0.js"></script>

        <script src="js/plugin/jquery.bxslider.min.js"></script>
        <link rel="stylesheet" type="text/css" href="js/plugin/jquery.bxslider.css"/>

        <script type="text/javascript" src="js/skripta.js"></script>


    </head> <!-- Head ends -->

and of course Im calling it inside separate .js file 当然我在单独的.js文件中调用它

$(document).ready(function() {

    $('.bxslider').bxSlider();

});

and the body is 身体是

<body> <!-- Body start -->
        <ul class="bxslider">
          <li><img src="js/plugin/images/pic1.jpg"/></li>
          <li><img src="js/plugin/images/pic2.jpg"/></li>
          <li><img src="js/plugin/images/pic3.jpg"/></li>
        </ul>

    </body><!-- Body ends -->

The issue is about jQuery version 3.0 and compatibility with bxslider.js . 问题是关于jQuery 3.0版和与bxslider.js兼容性。 And this issue was arised by jQuery .load() function. 这个问题是由jQuery .load()函数引起的。 You have to change bxslider.js 's one line to solve this issue. 你必须改变bxslider.js的一行来解决这个问题。 Open your bxslider.js file and find .load() function's code line. 打开你的bxslider.js文件,找到.load .load()函数的代码行。 It was used only 1 time in bxslider.js , so the necessary change is: 它在bxslider.js只使用了一次,因此必要的更改是:

From

$(this).load();

To

$(this).trigger('load');

There's a pull request on github that solves this: 在github上有一个pull请求解决了这个问题:

https://github.com/stevenwanderski/bxslider-4/pull/1024 https://github.com/stevenwanderski/bxslider-4/pull/1024

I'd recommend you test it out. 我建议你测试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM