2
關於此條目Loading Backbone and Underscore using RequireJS我很清楚如何配置Backbone
特定腳本和JQuery
。在Twitter中使用require.js Boostrap API和主幹
但我怎麼:
- 配置
Twitter bootstrap.js
? json2.js
?
謝謝!
關於此條目Loading Backbone and Underscore using RequireJS我很清楚如何配置Backbone
特定腳本和JQuery
。在Twitter中使用require.js Boostrap API和主幹
但我怎麼:
Twitter bootstrap.js
?json2.js
?謝謝!
除了您瞭解的路徑配置選項之外,您還應該查看墊片配置選項http://requirejs.org/docs/api.html#config-shim。
許多插件不是AMD準備好的,所以您有兩種選擇。無論是將其配置爲墊片(適用於大多數的插件),或在https://github.com/amdjs
簡單的例子編寫自己的適配器一樣的努力:
require.config({
shim: {
'bootstrap': ['jquery'], // no exports
'underscore': { exports: '_' }, // no dependencies
'backbone.layoutmanager': {
deps: ['backbone']
exports: 'Backbone.LayoutManager'
} // a mix of exports and dependencies
}
});
對於像json2它沒有依賴關係,並只激活,如果瀏覽器沒有本地實現,您可以簡單地將它列爲主應用程序需求的依賴項,而無需封裝/填充。