gpt4 book ai didi

javascript - jquery/underscore/backbone/parse 模块的 Require.js 加载超时

转载 作者:行者123 更新时间:2023-12-01 14:15:19 25 4
gpt4 key购买 nike

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#timeout

我在 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.jsapp.jsrouter.js 代码。

主要.js:

// Author: Thomas Davis <thomasalwyndavis@gmail.com>
// 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();
});

应用程序.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
};
});

路由器.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-jquery。它的 requirejs 版本已准备好与 jquery 一起使用并尝试使用 shim 配置。

请参阅此链接:https://github.com/jrburke/require-jquery

垫片配置示例:

require.config({
paths: {
"jqueryUI": "libs/jquery-ui",
"jquery": "libs/jquery-1.9.1",
"underscore": "libs/underscore-min",
"backbone": "libs/backbone-min"
},
shim: {
jqueryUI:{
deps: ["jquery"],
exports:"$"
},
underscore: {
exports: "_"
},
backbone: {
deps: ["underscore", "jquery"],
exports: "Backbone"
}
}

});

关于javascript - jquery/underscore/backbone/parse 模块的 Require.js 加载超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10902744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com