0

AbstractProductCollection.js:

define([
  'app',
  'models/AbstractProductModel',
  'models/ProductModel', 
  'models/PackageModel'
],
function (app, AbstractProductModel, ProductModel, PackageModel) {

    return Backbone.Collection.extend({

        model: AbstractProductModel,

        url: app.config.apiUrl + '/product',

        parse: function(response, options) {
            return _(response.data.abstractProduct).map(function(attrs) {
                switch (attrs.productTypeId) {
                    case 1:
                        return new ProductModel(attrs);
                    case 6:
                        return new PackageModel(attrs);
                }
            });
        }
    });
});

包模型.js:

define([
  'underscore',
  'backbone',
  'app',
  'models/AbstractProductModel',
  'collections/AbstractProductCollection'
],
function (_, Backbone, app, AbstractProductModel, AbstractProductCollection) {

    var PackageModel = AbstractProductModel.extend({

        defaults: {
        },

        initialize : function(){
            this.products = new AbstractProductCollection(this.get('products'));
        }

    });

    _.defaults(PackageModel.prototype.defaults, AbstractProductModel.prototype.defaults);
    _.defaults(PackageModel.prototype.initialize, AbstractProductModel.prototype.initialize);

    return PackageModel;

});

我收到此错误:未捕获的类型错误:未定义不是函数 PackageModel.js:17。AbstractProductCollection 在调试器中未定义。

任何人都可以解决这个问题吗?

4

0 回答 0