gpt4 book ai didi

javascript - Requirejs 出现媒体元素错误

转载 作者:行者123 更新时间:2023-11-28 01:51:28 25 4
gpt4 key购买 nike

我正在使用 require.js 加载我的 js 文件,并尝试加载 mediaelementplayer 但收到两个错误。 mejs 未定义,对象没有方法。有没有办法可以延迟这个文件的加载,即使 jQuery 首先加载并且媒体元素具有 jQuery 作为依赖项?我尝试将它放入 jquery 加载函数中,但这并没有改变任何东西。 Error

最佳答案

所编写的 MediaElementPlayer 依赖于 jquery,因此相应地进行了 shim(即 jquery 在 me 之前!!)

requirejs.config({
"paths": {
"jquery" : "libs/jquery/jquery-1.10.2.min",
"mes" : "libs/mes/mediaelement-and-player.min"
},
shim: {
'jquery': {
exports: '$'
},
'mes' : ['jquery']
}
});

然后

require(["jquery","mes"], function($){
$('video').mediaelementplayer({});
});

希望它能帮助其他人搜索这个。如果您使用的是 IE6-9,您可能需要 html5shiv

关于javascript - Requirejs 出现媒体元素错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19641511/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com