このエントリLoading Backbone and Underscore using RequireJSに関して、Backbone
固有のスクリプトとJQuery
.
しかし、どうすればいいですか:
- 構成します
Twitter bootstrap.js
か? - どう
json2.js
ですか?
ありがとう!
このエントリLoading Backbone and Underscore using RequireJSに関して、Backbone
固有のスクリプトとJQuery
.
しかし、どうすればいいですか:
Twitter bootstrap.js
か?json2.js
ですか?ありがとう!
path 構成オプションについて学んだことに加えて、shim 構成オプションhttp://requirejs.org/docs/api.html#config-shimも確認する必要があります。
多くのプラグインは AMD に対応していないため、2 つのオプションがあります。シム (ほとんどのプラグインに適しています) として構成するか、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 のようなものについては、ラッパー/シムなしで、メイン アプリケーションの require の依存関係として単純にリストすることができます。