未捕获的错误:引导的JavaScript jQuery的需要与requirejs [英] Uncaught Error: Bootstrap's JavaScript requires jQuery with requirejs
问题描述
我越来越没有定义这个错误,说jQuery的。
I am getting this error that says jQuery is not defined.
bootstrap.js:8未捕获的错误:引导的JavaScript需要jQuerybootstrap.js:8(匿名函数)
bootstrap.js:8 Uncaught Error: Bootstrap's JavaScript requires jQuerybootstrap.js:8 (anonymous function)
引导3.3.0
jQuery JavaScript库V2.1.3
jQuery JavaScript Library v2.1.3
requirejs
requirejs
require.config({
shim: {
'backbone': {
deps: ['underscore', 'jquery']
},
'backbone-validation': {
deps: ['backbone', 'jquery']
},
'jquerymx': {
deps: ['jquery']
},
'bootstrap': {
deps: ['jquery']
}
},
paths: {
'jquery': '/public/js/lib/jquery-2.1.3',
'jquerymx': '/public/js/lib/jquerymx-3.2.custom',
'bootstrap': '/public/js/lib/bootstrap',
'handlebars': '/public/js/lib/handlebars-v2.0.0',
'underscore': '/public/js/lib/underscore',
'backbone': '/public/js/lib/backbone',
'backbone-validation': '/public/js/lib/backbone-validation'
}
});
require(
[
'order!jquery',
'order!jquerymx',
'order!bootstrap',
'order!handlebars',
'order!underscore',
'order!backbone',
'order!backbone-validation'
], function () {
require(['main'], function (main) {
main.initialize();
});
});
是有什么错在这里?
is there something wrong here?
感谢。
推荐答案
一些建议:
首先,订单
插件不再支持或必要的RequireJS 2.0。在垫片
配置完全能够EX pressing你需要做什么。 看到这里了解详情。
First, the order
plugin is no longer supported or necessary in RequireJS 2.0. The shim
configuration is fully capable of expressing what you need to do. See here for details.
二,我有点困惑,为什么你有两个的jQuery
和 jquery.min
列为依赖关系。他们应该提供同样的事情,与 jquery.min
只是作为一个更小的文件。当你在同一个code拉两次,这可能是这里发生了什么一些JS可能会不知所措。尝试从配置中删除 jquery.min
的所有实例。
Second, I'm a little confused why you have both jquery
and jquery.min
listed as dependencies. They should provide the exact same thing, with jquery.min
just being a smaller file. Some JS can get confused when you pull in the same code twice, which might be what's happening here. Try removing all instances of jquery.min
from your configuration.
最后,你的两个阶段的要求(...)
通话不出现是必要的。假设你的主
模块列出它直接所需的库,你应该能够只是做:
Finally, your two-phased require(...)
call doesn't appear to be necessary. Assuming your main
module lists the libraries it needs directly, you should be able to just do:
require(['main'], function (main) {
main.initialize();
});
如果上述建议没有帮助,请提供更多的细节 - 即什么是主
模块中。
If the above suggestions don't help, please provide more details -- i.e. what is in the main
module.
这篇关于未捕获的错误:引导的JavaScript jQuery的需要与requirejs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!