未捕获错误:声明:mixin#0不是可调用的构造函数

时间:2014-04-12 14:29:49

标签: dojo

我使用以下代码:

require([
    "dojo/_base/declare",
    "dojo/ready", 
    "dijit/registry", 
    "dojox/mobile/ListItem",
    "dojox/mobile/EdgeToEdgeList",
    "dojo/dom-construct",
    "dojox/mobile/ProgressBar",
    "dojo/parser", 
    "dojox/mobile",
    "dojox/mobile/compat", // For non-webkit browsers (FF, IE)
    "dojox/mobile/ScrollableView"
], function(declare, ready, registry, ListItem, LongListMixin,
    EdgeToEdgeList, domConstruct, ProgressBar) {

    ready(function() {
        console.log("inside init Videos2");
        mainRegistry = registry;
        scrollableListItem = ListItem;
        ..........

我收到以下错误:

Uncaught Error: declare: mixin #0 is not a callable constructor.

2 个答案:

答案 0 :(得分:2)

我假设您正在某处使用dojox/mobile/LongListMixin添加为mixin。问题是您未在require()列表中包含该模块。

根据您的参数,您需要LongListMixindojox/mobile/ListItem之间的dojox/mobile/EdgeToEdgeList。将其添加到那里,以便require()成为:

require([
    "dojo/_base/declare",
    "dojo/ready", 
    "dijit/registry", 
    "dojox/mobile/ListItem",
    "dojox/mobile/LongListMixin", // This was missing
    "dojox/mobile/EdgeToEdgeList",
    "dojo/dom-construct",
    "dojox/mobile/ProgressBar",
    "dojo/parser", 
    "dojox/mobile",
    "dojox/mobile/compat", // For non-webkit browsers (FF, IE)
    "dojox/mobile/ScrollableView"
], function(declare, ready, registry, ListItem, LongListMixin,
    EdgeToEdgeList, domConstruct, ProgressBar) {

    // ...

});

如果你没有添加它,列表中的下一个参数(dojox/mobile/EdgeToEdgeList)将被映射到LongListMixin参数,从而导致错误,因为这并不是真正的预期

答案 1 :(得分:2)

对我来说,错误意味着我的需求清单中的文件是假的。意味着dojo无法使用它。这是我创建的文件。一旦我把那个错误消失了,我得到了我想要的结果。