我有一个名为stat.widget.Weekly
的小工具,它是_Container
,而require
的{{1}}为stat.widget.Daily
,但每当我使用{{1}时我得到了
Daily
我的代码就像这样
new Daily()
但是这个Uncaught TypeError: undefined is not a function
可以在require([
"dojo/_base/declare", "dojo/parser", ..., "stat/widget/Daily", "dijit/_Container"
], function(declare, ... , _WidgetBase, _TemplatedMixin, Daily, _Container){
declare("stat.widget.Weekly", [_WidgetBase, _TemplatedMixin, _Container], {
....
update: function(){
new Daily();//< Fires Error
},
postCreate: function(){
var self = this;
setTimeout(function(){
self.update();
}, 500);
}
});
});
答案 0 :(得分:0)
如果你的stat.widget.Weekly放在stat-Modulepath / widget / Daily.js下的一个文件中,这个语法在类加载器中处理起来会更顺利:
define([ // using define instead of require
"dojo/_base/declare", "dojo/parser", ..., "stat/widget/Daily", "dijit/_Container"
], function(declare, ... , _WidgetBase, _TemplatedMixin, Daily, _Container){
var myPrivates = declare("stat.widget._WeeklyResource", [], {
...
});
var myDefinition = declare("stat.widget.Weekly", [_WidgetBase, _TemplatedMixin, _Container], {
...
});
// returning the definition
return myDefinition;
});