Uncaught Error: Load timeout for modules: order!libs/jquery/jquery-min order!libs/underscore/underscore-min order!libs/parse/parse-min libs/jquery/jquery-min libs/underscore/underscore-min libs/parse/parse-min Backbone http://requirejs.org/docs/errors.html#timeoutRequire.js負載超時的jQuery /下劃線/骨幹網/解析模塊
我有Chrome瀏覽器的網絡選項卡下,沒有404名的請求,我也沒有腳本錯誤,所以我共同的錯誤/修正之外該問題(根據requirejs.org)。
當我看着我的網絡,我看到腳本加載順序如下:
require.js
main.js
app.js <-- required by main.js
order.js <-- used in main.js to require the next 4 scripts (which aren't AMD)
jquery-min.js <-- required by main.js
underscore-min.js <-- required by main.js
backbone-min.js <-- required by main.js
parse-min.js <-- required by main.js
router.js
login.js
text.js
這似乎是我的權利。以下是我的代碼main.js
,app.js
和router.js
。
main.js:
// Author: Thomas Davis <[email protected]>
// Filename: main.js
// Require.js allows us to configure shortcut alias
// Their usage will become more apparent futher along in the tutorial.
require.config({
paths : {
jQuery : 'libs/jquery/jquery-min',
Underscore : 'libs/underscore/underscore-min',
Backbone : 'libs/backbone/backbone-min',
Parse : 'libs/parse/parse-min',
templates : '../templates'
}
});
require([
// Load our app module and pass it to our definition function
'app',
// Some plugins have to be loaded in order due to their non AMD compliance
// Because these scripts are not "modules" they do not pass any values to the
// definition function below
'order!libs/jquery/jquery-min',
'order!libs/underscore/underscore-min',
'order!libs/backbone/backbone-min',
'order!libs/parse/parse-min'
],
function(App) {
// The "app" dependency is passed in as "App"
// Again, the other dependencies passed in are not "AMD" therefore
// don't pass a parameter to this function
App.initialize();
});
app.js:
// Filename: app.js
define([ 'jQuery', 'Underscore', 'Parse', 'router' ],
function($, _, Parse, Router) {
var initialize = function() {
Parse.$ = $;
// Initialize Parse with your Parse application javascript keys
Parse.initialize("HIDDEN", "ALSO HIDDEN");
// Pass in our Router module and call it's initialize function
Router.initialize();
};
return {
initialize : initialize
};
});
router.js:
// Filename: router.js
define([ 'jQuery', 'Underscore', 'Backbone', 'Parse', 'views/home/login', ],
function($, _, Backbone, Parse, loginView) {
var AppRouter = Backbone.Router.extend({
routes : {
// Default
'*actions' : 'defaultAction'
},
defaultAction : function(actions) {
// We have no matching route, lets display the home page
loginView.render();
}
});
var initialize = function() {
var app_router = new AppRouter;
Backbone.history.start();
};
return {
initialize : initialize
};
});
我得到這會爲你工作,但因此它並沒有真正的答案,這並不使用requireJS到了加載模塊這個問題... –
這幾乎違背了AMD的原則。 –