问题
Basically I want to be able to load some module first before other. For example, I want bootstrap to load first before backbone. Can I declare dependencies like so?
shim: {
'backbone': {deps: ['bootstrap']}
}
回答1:
Yes, that is the way to do it (in the require.config({ ... block of course.) It is also recommended to add an exports key and set it to Backbone. This will allow you to use Backbone inside a require or define block, as though it were a real AMD module:
define(['backbone'], function (Backbone) {
// Backbone here is the function parameter instead of the global reference
});
Read more here. In fact they even reference Backbone as their example!
来源:https://stackoverflow.com/questions/20696465/requirejs-how-to-define-extra-dependencies-for-3rd-party-library