我正在尝试加载
textext.js
jquery插件,其中一个插件,
textext tags
在我的项目中,我使用require.js来加载所有脚本及其依赖项。
与其他脚本一样,我在我的
main.js
文件:
main.js
require.config({
shin: {
jquery: {
exports: '$'
},
'textext': {
deps: ['jquery'],
exports: '$.fn.textext'
},
'textext_tags': {
deps: ['jquery', 'textext'],
}
},
paths: {
jquery: 'lib/jquery-min',
textext: 'lib/textext/textext.core',
textext_tags: 'lib/textext/textext.plugin.tags',
}
});
在我使用它的页面上,我这样称呼它:
文件app.js
define([
'jquery',
'textext',
'textext_tags',
], function($, Textext, TextextTags) {
// do stuff
});
代码在firefox上加载并正常工作,但在Chromium上,有时(大约2/3的时间),在我第一次加载页面时,我收到了以下错误,这破坏了页面的功能:
TypeError: Cannot set property 'TextExtTags' of undefined
#3 localhost/js/lib/textext/textext.plugin.tags.js:23:27
文件内部
textext.plugins.tags.js
,第23行(故障线):
$.fn.textext.TextExtTags = TextExtTags;
所以,用Firebug检查它,我发现Jquery没有加载,所以
$
和
$.fn
未定义。
我的问题是:为什么require.js的这个模式与同一项目中的其他jQuery插件(如jQuery cookie和其他插件)一起工作,而不是与带有子插件的jQuery插件一起工作?