你想是這樣的:
require.config({
baseUrl: "/js/",
paths: {
jquery: 'libs/jquery/jquery-1.7.1',
'jquery.mobile-config': 'libs/jqm/jquery.mobile-config',
'jquery.mobile': 'libs/jqm/jquery.mobile-1.1.0',
'jquery.mobile.asyncfilter': 'libs/jqm/asyncfilter',
underscore: 'libs/underscore/underscore-1.3.3',
backbone: 'libs/backbone/backbone-0.9.2',
templates: '../templates'
},
shim: {
'underscore': {
exports: "_"
},
'backbone': {
//These script dependencies should be loaded before loading
//backbone.js
deps: ['jquery','underscore'],
//Once loaded, use the global 'Backbone' as the
//module value.
exports: 'Backbone'
},
'jquery.mobile-config': ['jquery'],
'jquery.mobile': ['jquery','jquery.mobile-config'],
'jquery.mobile.asyncfilter': ['jquery.mobile'],
}
});
require([
'jquery',
'app',
'jquery.mobile','jquery.mobile.asyncfilter'
], function($, App){
$(function(){
App.initialize();
});
});
在你的情況,你會用jquery-ui的東西來替換jquery-mobile的東西。同樣的想法。 Jquery非常聰明,可以將自己置於全局命名空間中,其餘的根據你的版本而不是(通常來說)。希望這可以幫助你。請記住,如果你使用不兼容的庫,你會想把它扔在墊片中,就像你上面看到的那樣。墊片是手動包裝庫的捷徑(又名,你自己)。
有趣的是,我認爲使用腳本加載的單一方法確實更加清潔,我會更多地考慮這一點,並稍後參考您的示例。謝謝 – Flosculus