我有一个非常基本的模型和控制器。但是,当我执行脚本时,出现以下错误: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",
    }
});

最佳答案

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

return {
    dropdownModel: dropdownModel
};


您可能只想这样做:

return dropdownModel;

09-27 04:05