错误:..不是Backbone中的构造函数

时间:2016-07-29 18:57:28

标签: javascript backbone.js requirejs

我有一个非常基本的模型和控制器。但是当我执行脚本时,我得到错误:Uncaught TypeError: dropdownModel is not a constructor

型号:

define(['backbone'], function(Backbone) {
    var dropdownModel = Backbone.Model.extend();
    return {
        dropdownModel: dropdownModel
    };
});

控制器:

define(['backbone', 'dropdownModel'],
  function(Backbone, dropdownModel ) 
  {
    var dropdownModel = new dropdownModel({});
});

需要模块:

requirejs.config({
    baseUrl: "../Scripts",
    paths: {
        requireLib: "../Scripts/require",
        dropdownModel: "../Models/dropdownModel",
        firstDashboardController: "../Controller/firstDashboardController",
    }
});

1 个答案:

答案 0 :(得分:2)

您要在此行导出对象而不是模型本身:

return {
    dropdownModel: dropdownModel
};

您可能只想这样做:

return dropdownModel;