我想使用 RequireJS 在我的主干.js 应用程序中包含 jQueryUI。我的 index.html 中包含的 main.js 文件如下:
require.config({
paths: {
jquery: 'libs/jquery/jquery-1.7.2.min',
jqueryui: 'libs/jquery/jquery-ui-1.8.18.custom.min',
underscore: 'libs/underscore/underscore-min',
backbone: 'libs/backbone/backbone-optamd3-min',
text: 'libs/require/text',
templates: 'templates'
}
});
require(['app'], function(App){
App.start();
});
对于每个模型/视图/路由器文件,我只在“定义”块的开头包含“jquery”命名空间,如下所示:
define([
'jquery',
'underscore',
'backbone',
'views/categoryview',
'text!templates/category.html'
], function($, _, Backbone, CategoryView, categoryTemplate){
// Here comes my code
});
但是 jQueryUI 不能在这些文件中使用。我的代码有问题吗?或者我还应该在每个“定义”块中包含“jqueryui”吗?但是如果我在“define”块中包含“jqueryui”,我应该如何在函数中命名它以避免与jquery发生名称冲突?