[英]Require.js : Uncaught TypeError: Object function … has no method
I'm getting an Uncaught TypeError when i refresh the page, my js/app/main.js file can't call the method update() on js/app/utilities/resize.js . 刷新页面时出现Uncaught TypeError,我的js / app / main.js文件无法在js / app / utilities / resize.js上调用方法update()。
Uncaught TypeError: Object function U(n){return n&&typeof n=="object"&&!me(n)&&ne.call(n," wrapped ")?W(n)} has no method 'update'
未捕获的TypeError:对象函数U(n){返回n && typeof n ==“ object” &&!me(n)&& ne.call(n,“ 包装的 ”)?W(n)}没有方法'update'
I haven't managed to isolate/replicate the issue into a simplified working example unfortunately. 不幸的是,我没有设法将问题隔离/复制为一个简化的工作示例。 But you can click on the js files within the folder tree below for gists.
但是您可以在下面的文件夹树中单击js文件,以获得要点。
require.config({
urlArgs: "bust=" + (new Date()).getTime(),
baseUrl: WP.THEME_URL+"/js",
paths: {
app : "app"
, jquery : "lib/jquery-2.0.2.min"
, ...
, resize : "app/utilities/resize"
, ...
}
});
require(["app/main"],function(){});
The method update() is being called on resize.js from main.js ; 在main.js的resize.js上调用了update()方法;
define([ 'require' , 'jquery' , ... ,'resize' ], function( require , $ , ... , resize ) {
define(['require','jquery',...,'resize'],function(require,$,...,resize){
...
...
function setup() {
函数setup(){
resize.update(); // Uncaught TypeError happens here
}
}
$doc.ready( setup );
$ doc.ready(setup);
define([],function () {
var resizeItems = [],
update = function () {
for (i = 0; i < resizeItems.length; i++){
var item = resizeItems[i];
item.callback( App.screen.width , App.screen.height );
}
};
return {
update : update,
add : function( item ) { resizeItems.push( item ); }
}
});
Thanks in advance 提前致谢
Edit : It seems it was a dependancy issue. 编辑 :似乎这是一个依赖问题。 Adding "resize" to require on app.js has resolved it;
在app.js上添加要求的“调整大小”已解决该问题;
require(["resize","app/main"],function(){});
I thought suppling "resize" to define() in main.js would have ensured correct deps; 我认为在main.js中提供“ resize”到define()可以确保正确的deps。
define([ 'require' , 'jquery' , ... ,'resize' ], function( require , $ , ... , resize )...
It seems it was a dependancy issue. 看来这是一个依赖问题。
Adding "resize" to require() within app.js has resolved it; 在app.js中的require()中添加“ resize”可以解决该问题;
require(["resize","app/main"],function(){});
I thought suppling "resize" to define() in main.js would have ensured correct deps; 我认为在main.js中提供“ resize”到define()可以确保正确的deps。
define([ 'require' , 'jquery' , ... ,'resize' ], function( require , $ , ... , resize )...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.