jQuery Slider Uncaught TypeError: Object #<Object>没有方法“数据" [英] jQuery Slider Uncaught TypeError: Object #<Object> has no method 'data'

查看:19
本文介绍了jQuery Slider Uncaught TypeError: Object #<Object>没有方法“数据"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误这里

错误内容如下:Uncaught TypeError: Object # has no method 'data'

The error reads: Uncaught TypeError: Object # has no method 'data'

我终其一生都无法弄清楚这个错误是从哪里来的!

I cannot figure out for the life of me where this error is originating from!

如果有人有任何线索,请告诉我!

If anyone has even the slightest clue, please let me know!

谢谢,

埃文

推荐答案

它源自jquery.nivo.slider.pack.js",更准确地说是在第 67 行抱怨 element.data is not a function(Firebug 是进行此类调试的绝佳工具:-)).我不完全确定,但这可能是因为您的 html 中的以下代码:

It's originating from "jquery.nivo.slider.pack.js" and more precisely is complaining about element.data is not a function at line 67 (Firebug is a great tool for such debugging :-) ). I am not entirely sure, but it could be because of the following code in your html:

<script type="text/javascript">
$(window).load(function() {
    $('#slider').nivoSlider();
});
</script>

$(window).load 将在窗口加载后立即触发,此时可能是滑块 div 不存在于 DOM 中.因此,请尝试将其更改为:

$(window).load will fire as soon as the window is loaded at which point it could be that the slider div is not present in the DOM. So, try changing this to:

<script type="text/javascript">
$(document).ready(function() {
    $('#slider').nivoSlider();
});
</script>

这将确保 DOM 已绘制并可供插件使用.此外,看起来插件需要一个元素"参数,而您没有传递任何参数,这可能是 element.data 未定义的原因.为此,您可以尝试:

This will ensure that the DOM has been painted and available for the plugin to work on. Also, it looks like the plugin expects an 'element' argument, whereas you are passing none, which could be the reason for element.data to be undefined. For this you can try:

$('#slider').nivoSlider($(this));

希望其中一个对你有用.

Hope one of them works for you.

这篇关于jQuery Slider Uncaught TypeError: Object #&lt;Object&gt;没有方法“数据"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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