骨干网收集网址能否取决于模型urlRoot?例如

var _User = Backbone.Model.extend({
    urlRoot: '/api/users',
    defaults: {
        email: ''
    }
});

var _Users = Backbone.Collection.extend({
    url: function() {
        return this.model.urlRoot;
    },
    model: _User
});

最佳答案

看起来像你想要的

var _User = Backbone.Model.extend({
    urlRoot: '/api/users',
    defaults: {
        email: ''
    }
});

var _Users = Backbone.Collection.extend({
    url: function url() {
      return this.model.prototype.urlRoot;
    },
    model: _User
});

09-26 13:50