加载Backbone.Use使用关系!插入 [英] Loading Backbone.Relational using Use! plugin
问题描述
Backbone Relational不是AMD兼容的库,因此我继续进行研究,发现使用插件可确保下划线和主干都作为依赖项加载.这是我的配置文件
Backbone Relational is not an AMD compliant library, so I've gone ahead and found the use plugin to ensure underscore and backbone are both loaded as dependencies. Here is my config file
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库
I've also gone ahead and augmented the Backbone Relational library
(function(Backbone, _) {
"use strict";
Backbone.Relational = {
showWarnings: true
};
})(this.Backbone, this._);
最后,我在模型中调用关系式
Finally, I am calling relational within a model
define([
'jquery',
'underscore',
'backbone',
'mediator',
'relational'
], function($, _, Backbone, Mediator){
我收到一个错误,无法设置未定义的属性Relational.含义骨干网不可用.我想念什么?
I am getting an error of cannot set property Relational of undefined. Meaning Backbone is not available. What am I missing?
我一直在使用的某些链接
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
Some links that I have been using
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
推荐答案
要使用(原文如此)use
插件,您不需要下划线/主干的AMD版本.
尽管确实需要包装它们,即在您的require config中具有:
To use (sic) the use
plugin you do not need the AMD versions of underscore/backbone.
You do need to wrap them though accordingly, i.e. in your require config have:
use: {
backbone: {
deps: ["use!underscore", "jquery"],
attach: "Backbone"
},
underscore: {
attach: "_"
},
relational: {
deps: ["use!underscore", "use!backbone"]
}
....
}
这篇关于加载Backbone.Use使用关系!插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!