jQuery 滑块未捕获类型错误:对象#<对象>没有方法“data”;对象>
我收到以下错误 此处
错误内容如下: Uncaught TypeError: Object # has no method 'data'
我一辈子都无法弄清楚这个错误是从哪里来的!
如果有人有哪怕一点线索,请告诉我!
谢谢你,
埃文
I am getting the following error HERE
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!
Thank you,
Evan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它源自“jquery.nivo.slider.pack.js”,更准确地说,是在第 67 行抱怨 element.data 不是一个函数(Firebug 是进行此类调试的一个很好的工具:-))。我不完全确定,但这可能是因为您的 html 中包含以下代码:
$(window).load 将在窗口加载后立即触发,此时滑块 div 可能不存在于 DOM 中。因此,尝试将其更改为:
这将确保 DOM 已被绘制并且可供插件使用。另外,看起来插件需要一个“element”参数,而您没有传递任何参数,这可能是 element.data 未定义的原因。为此,您可以尝试:
希望其中之一适合您。
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:
$(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:
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:
Hope one of them works for you.
如果有人遇到同样的问题,live() 已被弃用,替换为 on(),您需要使用较新版本的 nivo 或较旧版本的 jquery,jquery-1.8.0 可以工作。
Incase anyone is stuck with the same thing, live() is deprecated replaced with on(), you need to use a newer version of nivo or an older version of jquery, jquery-1.8.0 works.