Backbone Relational 不是 AMD 兼容的库,所以我继续寻找使用插件来确保下划线和主干都作为依赖项加载。这是我的配置文件
require.config({
baseUrl: '../global/js',
paths: {
use: 'libs/utilities/use',
jquery: 'libs/jquery/jquery-min',
underscore: 'libs/underscore/underscore-min',
backbone: 'libs/backbone/backbone-optamd3-min',
text: 'libs/require/text',
relational: 'libs/backbone/backbone-relational'
},
use: {
"relational": {
deps: ["backbone","underscore"]
}
}
});
我还继续扩展了 Backbone Relational 库
(function(Backbone, _) {
"use strict";
Backbone.Relational = {
showWarnings: true
};
})(this.Backbone, this._);
最后,我在模型中调用关系
define([
'jquery',
'underscore',
'backbone',
'mediator',
'relational'
], function($, _, Backbone, Mediator){
我收到无法设置未定义的属性关系的错误。含义 Backbone 不可用。我错过了什么?
我一直在使用的一些链接
https://github.com/tbranyen/use.js
https://github.com/tbranyen/layoutmanager-example/blob/master/app/index.js
https://raw.github .com/PaulUithol/Backbone-relational/master/backbone-relational.js