[英]No define call function in Require.js
I have errors loading jquery-menu-aim
and bootstrap
with Require.js in backbone project. 我在主干项目中使用Require.js加载
jquery-menu-aim
和bootstrap
时出错。
Here are what I had defined in main.js of : 这是我在main.js中定义的内容:
requirejs.config({
enforceDefine: true,
paths: {
//declare path jquery, backbone, underscore,and other library here....
"jquery-menu-aim" : "libs/jquery/jquery.menu-aim",
"bootstrap" : "libs/jquery/bootstrap.min"
},
shim: {
"jquery-menu-aim" : {
deps: ["jquery"] ,
exports: "Jquerymenuaim"
},
"bootstrap" : {
deps: ["jquery"] ,
exports: "Bootstrap"
}
}
});
Errors : Uncaught Error: No define call for jquery-menu-aim http://requirejs.org/docs/errors.html#nodefine require.js:8 Uncaught Error: No define call for bootstrap http://requirejs.org/docs/errors.html#nodefine 错误:未捕获错误:对jquery-menu-aim没有定义调用http://requirejs.org/docs/errors.html#nodefine require.js:8未捕获错误:没有对引导程序http://requirejs.org/的定义调用文档/ errors.html#nodefine
When I defined it in my view. 当我在视图中定义它时。 I think maybe I was wrong in defining library in Shim config, but I can not found it in google.
我认为在Shim config中定义库可能是错误的,但在google中找不到。
Any help would be appreciated. 任何帮助,将不胜感激。 Thanks.
谢谢。
Your shim for Bootstrap is definitely wrong because Bootstrap does not define a symbol named Bootstrap
. 您的Bootstrap填充程序绝对是错误的,因为Bootstrap没有定义名为
Bootstrap
的符号。 Here's what I use: 这是我使用的:
bootstrap: {
deps: ["jquery"],
exports: "jQuery.fn.popover"
},
The jQuery.fn.popover
method is something that Bootstrap defines. jQuery.fn.popover
方法是Bootstrap定义的。 If it is absent after RequireJS has loaded Bootstrap, that's a sure sign that Bootstrap has not loaded. 如果在RequireJS加载Bootstrap之后不存在,则表明Bootstrap没有加载。
Your shim for jquery.menu-aim is similarly wrong. 您的jquery.menu-aim填充程序同样错误。 Looking at the code , I see it is a jQuery plugin.
查看代码 ,我看到它是一个jQuery插件。 You should change your shim to check for a function it adds to jQuery.
您应该更改垫片以检查它添加到jQuery的功能。
jQuery.fn.menuAim
looks like a good candidate. jQuery.fn.menuAim
看起来不错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.