bxslider指令抛出错误`未捕获的TypeError:无法读取未定义的属性'indexOf' [英] bxslider directive throwing error `Uncaught TypeError: Cannot read property 'indexOf' of undefined`

查看:523
本文介绍了bxslider指令抛出错误`未捕获的TypeError:无法读取未定义的属性'indexOf'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用了angularjs,我为bxslider创建了一个指令。下面是指令的代码:

pre $ angular.module('sbAdminApp')
.directive('bxSlider',function (){
return {
restrict:A,
require:ngModel,
link:function(scope,element,attrs,ctrl){
b.BlSlider({
maxSlides:1,
auto:true,
controls:false,
$(
$($(element [0]))
pager:true
});
})
}
}
})

上面我使用了这个 $($(element [0]))。bxSlider({函数为我搜索bxslider应该与ng-repeat一起使用的问题,并发现此解决方案之后bxslider正在工作,但有时图像无法加载,我总是可以看到此错误。


未捕获的TypeError:无法读取y'indexOf'of undefined



解决方案

p>

这不是一个angularjs错误,这是一个与bxslider兼容的jquery版本。

问题出现在jQuery <$在bxslider.js文件中找到 .load() .load()函数。

code>函数的代码行。它只在bxslider.js中使用过一次。





  $(本).load(); 

  $(本).trigger( '负载'); 

感谢kkakkurt提供这个出色的解决方案 https://stackoverflow.com/a/38562965/4119808


I am using angularjs in my application where I have created a directive for bxslider. Below is code of directive:

angular.module('sbAdminApp')
.directive('bxSlider', function(){
    return{
        restrict: "A",
        require: "ngModel",
        link: function(scope, element, attrs, ctrl){
            element.ready(function(){
                $($(element[0])).bxSlider({
                    maxSlides:1,
                    auto:true,
                    controls:false,
                    pager:true
                });
            })
        }
    }
})

Above I am using like this $($(element[0])).bxSlider({ after ready function as I search for a problem where bxslider should work with ng-repeat and found this solution after which bxslider is working but sometimes images doesn't load and I can see this error always.

Uncaught TypeError: Cannot read property 'indexOf' of undefined

解决方案

Finally i got the answer after so many searches

This is not a angularjs error this is a jquery version compatibility with bxslider.

Issue is arised by jQuery .load() function.

In bxslider.js file find .load() function's code line. It was used only 1 time in bxslider.js.

From

$(this).load();

To

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

Thanks to kkakkurt for this great solution https://stackoverflow.com/a/38562965/4119808

这篇关于bxslider指令抛出错误`未捕获的TypeError:无法读取未定义的属性'indexOf'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆