无法诊断 jQuery 错误:“对象 [对象对象] 没有方法”

发布于 2024-12-29 06:36:20 字数 496 浏览 7 评论 0原文

我正在开发一个 Wordpress 主题,现在我正在尝试让 MediaElement 在帖子上显示音频文件。

jQuery 加载正常(使用 jQuery 警报进行测试),但由于某种原因 MediaElement 不想工作。我收到错误

'Object [object Object] has no method 'mediaelementplayer',' 

,尽管我已经仔细检查了所有内容,但我还是无法弄清楚出了什么问题。如果您需要该问题的现场演示,请在此处查看:http:// firstpersontheater.net/video/podcast/painkiller-already-episode-78(请不要评判主题,我正在努力先完成核心功能,但还没有真正开始设计,哈哈)。

I'm working on a Wordpress theme and right now I'm trying to get MediaElement to display audio files on posts.

jQuery is loading fine (tested with jQuery alerts) but for some reason MediaElement doesn't want to work. I get the error

'Object [object Object] has no method 'mediaelementplayer',' 

and although I've double checked everything I just can't figure out what's wrong. If you need a live demo of the problem, check it out here: http://firstpersontheater.net/video/podcast/painkiller-already-episode-78 (please don't judge the theme, I'm working on getting core functionality done first and haven't really started designing yet, haha).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

Saygoodbye 2025-01-05 06:36:20

这对我的 WordPress 插件有用:

mejs.$('.mejs-player').mediaelementplayer();

This worked for me with the WordPress plugin:

mejs.$('.mejs-player').mediaelementplayer();
娇女薄笑 2025-01-05 06:36:20

昨天也遇到这个问题了。

MediaElement.js 实际上在下载包中包含几个不同的文件。为了获得全功能的视频播放器,您必须包含“mediaelement-and-player.js”文件,而不是“mediaelement.js”文件,后者只是库。

Had this problem yesterday as well.

MediaElement.js actually includes several different files in the download package. In order to get the full-featured video player you have to include the "mediaelement-and-player.js" file, not the "mediaelement.js" file, which is just the library.

饮惑 2025-01-05 06:36:20

我遇到了同样的问题。

虽然我无法准确找出 MediaElement.js 的 WordPress 插件实现发生此错误的确切原因,但我仅使用 MediaElement 的 JavaScript 就可以解决这个问题。

我修改了 PHP 以输出相关的音频和视频 HTML 标签,无需 ID,也无需调用它们的脚本。我还删除了用于提示脚本的插件的各个方面,而是自己将它们链接到我的主题中。

然后我成功地使用 jQuery 正常调用 MediaElement。

I encountered this same issue.

While I was unable to isolate exactly why this error occurs with the WordPress plug-in implementation of MediaElement.js, I was able to move past it by using the JavaScript of MediaElement only.

I modified the PHP to output the relevant audio and video HTML tags without ID's, and without the script that calls them. I also removed the aspects of the plug-in for cueing scripts, instead linking them myself in my theme.

I then had success calling MediaElement normally using jQuery.

梦里南柯 2025-01-05 06:36:20

那么您使用什么库来添加 api mediaelementplayer ?看起来该插件要么未正确加载,要么您错误地使用了 API。

Well what library are you using that adds the api mediaelementplayer? Looks like that plugin either isnt loaded correctly or you are using the API incorrectly.

半步萧音过轻尘 2025-01-05 06:36:20

快速回答:

您试图调用一个不退出的方法。

var o = {a = 1, b = 2};
o.someFunctionIThinkShoudExist();

如果它能显示您尝试调用的函数的名称,那就太好了。上周我就遇到了这种情况,我通过确保链接到正确的 JavaScript 文件解决了这个问题。

您可以检查的是,您仅链接到正在使用的库(例如 jQuery)一次。如果您链接到 jQuery 和 jQuery 扩展,则再次链接到 jQuery 将取消绑定扩展。当您尝试调用您认为应该退出的函数时,会导致上述错误。

Quick answer:

You trying to to call a method that does not exits.

var o = {a = 1, b = 2};
o.someFunctionIThinkShoudExist();

It would be nice if it showed what the name of the function you were trying to call was. This happened to me last week and I resolved it by making sure I had linked to the correct JavaScript files.

What you can check is that you are only linking to the libraries you are using, like jQuery, only once. If you link to jQuery and a jQuery extention, then linking to jQuery again will unbind the extension. Causing the above error when you try to call the function you think should exits.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文