キャッシュをクリアした後のアプリの初期ロード時に、jquery is undefined bc が表示されます。アプリは、jquery がロードされる前に jquery validate をロードしようとしています。更新後、すべてが読み込まれ、正常に動作します。これを正しく設定したと思っていましたが、何か不足していますか? backbone.js、require.js、jquery を使用します。
Main.js:
require.config({
paths: {
'jquery': 'libs/jquery/jquery-min',
'underscore': 'libs/underscore/underscore-min',
'backbone': 'libs/backbone/backbone-min',
'validate': 'jquery.validate-1.11.1.min',
'templates': '../templates'
},
shim: {
jquery: {
exports: "jquery"
},
underscore: {
exports: '_'
},
backbone: {
deps: ['underscore', 'jquery'],
exports: "backbone"
},
validate: {
deps: ['jquery'],
exports: "validate"
}
},
});
require([
'app'
], function(App){
App.initialize();
});
App.js
define([
'jquery',
'underscore',
'backbone',
'validate',
'router',
'scripts'
], function($, _, Backbone, validate, Router, scripts){
var initialize = function(){
Router.initialize();
};
return {
initialize: initialize
};
});
これが私がファイルを更新したものですが、まだ運がありません:
require.config({
paths: {
'jquery': 'libs/jquery/jquery-min',
'underscore': 'libs/underscore/underscore-min',
'backbone': 'libs/backbone/backbone-min',
'validate': 'jquery.validate-1.11.1.min',
'templates': '../templates'
},
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: ['underscore', 'jquery'],
exports: "Backbone"
},
validate: {
deps: ['jquery', 'backbone'],
exports: "validate"
}
}
});
require([
'app'
], function(App){
App.initialize();
});
App.js
define([
'jquery',
'underscore',
'backbone',
'validate',
'router',
'scripts'
], function($, _, Backbone, validate, Router, scripts){
var initialize = function(){
Router.initialize();
};
return {
initialize: initialize
};
});