[英]Uncaught TypeError: Object function ()
I wrote the following functions. 我写了以下函数。 At run time the browser complains about uncaught TypeError ...has no method 'init'.
在运行时,浏览器抱怨未捕获的TypeError ...没有方法'init'。 What's wrong of my code?
我的代码有什么问题?
function build_results_grid (response) {
// build grid
grid_ui.init();
} // build the results grid
var grid_ui = function () {
return {
init: function () {
//build_grid();
}
}; // return
}
You assigned grid_ui
to a function, without calling it. 您
grid_ui
分配给一个函数,而没有调用它。
Change that to 更改为
var grid_ui = (function() { ... })();
since a call to grid_ui is necessary to return the function with init inside, you need 由于必须调用grid_ui才能返回内部带有init的函数,因此您需要
grid_ui().init();
Since grid_ui must be called. 由于必须调用grid_ui。 Or you can make
grid_ui
be the return of the call, as SLaks did 或者你可以让
grid_ui
是调用的返回,因为SLaks做
EDIT - I misread your braces, if you noticed the question I had here before you can disregard it. 编辑-如果您在忽略此括号之前注意到了我在这里遇到的问题,则我误读了您的括号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.