此問題僅在Internet Explorer 9中出現,可與Chrome和Firefox一起正常工作。Internet Explorer中模塊的加載超時
這裏是一個載入我的所有依賴我的主要文件:
// Filename: main.js
// Require.js allows us to configure shortcut alias
// There usage will become more apparent futher along in the tutorial.
require.config({
paths: {
jQuery: 'libs/jquery/jquery',
Underscore: 'libs/underscore/underscore',
Backbone: 'libs/backbone/backbone',
JSON: 'libs/json2/json2',
templates: '../templates'
}
});
require([
// Load our app module and pass it to our definition function
'order!app',
// Some plugins have to be loaded in order due to there 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/json2/json2-src'
], 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();
});
這裏的地方的瀏覽器崩潰:
SomeRoute:function(){
facade.console.log("SomeRoute");
$("#toDelete").remove();
this.user = new User($.cookies.get('User'));
var that = this;
require(['views/SomeView'],function(SomeView){ // On this require
if(that.user.get('usr_id') > 0){
var view = new SomeView();
$("#domelement").append(that.changeView(view));
}
else window.location = APP_URL + "/login#login";
});
}
當我走這條路,我得到這個錯誤:
SCRIPT5022: Load timeout for modules: views/SomeView
http://requirejs.org/docs/errors.html#timeout
require.js, Line 27 Char 311
但Chrome或Firefox中沒有任何內容,並且一切正常。
編輯:此外,刷新頁面我要求加載它非常好。只有當我走上一條路。我必須刷新才能訪問我的其他模塊內容。
編輯2:經過一些額外的測試後,我嘗試在我的main.js中添加「enforceDefine:true」,並更改了我的require調用。沒有改變。 此外,調用該功能的任何觀點...
confirmView: function(idDialog, view, opts1){
facade.loader("body");
require(["text!templates/common/dialog/confirm.phtml"], function(dialogTp){
var opts = $.extend({}, facade.dialog.defaultOpts, opts1);
// Delete previous dialog with same ID
$("#"+idDialog).remove();
// select the view we'll set
var el = "#"+idDialog+" .modal-body";
// Create our template with our options
var contentDialog = _.template(dialogTp, { "option": opts, "text": "", "id": idDialog});
$("body").append(contentDialog);
require([view], function(viewClasse){
viewClasse.setElement("#"+idDialog+" .modal-body");
opts.preLoad(viewClasse);
viewClasse.render();
facade.unloader("body");
// twitter modal instance
facade.dialog.events(idDialog, opts, viewClasse);
$("#"+idDialog).modal(opts.modal);
});
});
}
...會崩潰藏漢(超時)。
我真的不知道發生了什麼...
感謝您的任何幫助。
謝謝,我會盡力並通知你。 – Sky 2012-07-26 13:24:40
不能告訴你它是怎麼回事,我在RequireJS 2.0中有多重錯誤,對於一個先行者來說很難。我一直在努力。 – Sky 2012-07-27 08:19:25
謝謝,我終於做到了(在另一篇文章中提供幫助),並使用RequireJS 2.0和shim config修復了Internet Explorer上的問題。 – Sky 2012-07-30 07:34:37