我想使用RelationalModel
using requireJs
。
这是我的代码(*)
当我运行我的模块时,我收到以下警告消息:
Relation=d;
no model, key or relatedModel (function (){a.apply(this,arguments)},
"tasks",
undefined).
我的问题是:
1)警告信息是什么意思?
2)relatedModel
并且在我的或我应该导出和调用中collectionType
明确定义?relations
model
collection
define
(*)
define([
'backbone',
'relationalModel'
], function (Backbone) {
"use strict";
var User = Backbone.RelationalModel.extend({
relations: [{
type: Backbone.HasMany,
key: 'tasks',
relatedModel: 'Task',
collectionType: 'TaskCollection',
reverseRelation: {
key: 'hasUser',
includeInJSON: 'id'
// 'relatedModel' is automatically set to 'User'; the 'relationType' to 'HasOne'.
}
}]
});
return User;
});