Backbone收集网址可以依赖于模型urlRoot吗?例如
var _User = Backbone.Model.extend({
urlRoot: '/api/users',
defaults: {
email: ''
}
});
var _Users = Backbone.Collection.extend({
url: function() {
return this.model.urlRoot;
},
model: _User
});
答案 0 :(得分:1)
看起来像你想要的
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
});