我从这里API读取了requirejs文档
requirejs.config({
shim: {
'backbone': {
//These script dependencies should be loaded before loading
//backbone.js
deps: ['underscore', 'jquery'],
//Once loaded, use the global 'Backbone' as the
//module value.
exports: 'Backbone'
},
'underscore': {
exports: '_'
},
'foo': {
deps: ['bar'],
exports: 'Foo',
init: function (bar) {
//Using a function allows you to call noConflict for
//libraries that support it, and do other cleanup.
//However, plugins for those libraries may still want
//a global. "this" for the function will be the global
//object. The dependencies will be passed in as
//function arguments. If this function returns a value,
//then that value is used as the module export value
//instead of the object found via the 'exports' string.
return this.Foo.noConflict();
}
}
}
});
但我没有得到垫片的一部分。为什么我应该使用垫片以及应该如何配置,我可以进一步澄清一下吗
请任何人举例说明为什么以及何时应使用垫片。谢谢。
Underscore
和Backbone
此处的用法与通常的shim
一样,在这种情况下该怎么办?我可以使用require( function() { _.extend({}); })
吗?懂_
吗?