gpt4 book ai didi

jquery - requirejs - 下划线模块未加载

转载 作者:行者123 更新时间:2023-12-01 08:00:29 26 4
gpt4 key购买 nike

看到错误 - 我不确定到底出了什么问题。页面/模块有时会加载,但很多时候我都会收到此错误。这是最新的下划线和 Backbone 模块。

Error: Module name 'underscore' has not been loaded yet for context: _ http://requirejs.org/docs/errors.html#notloaded

require.config({
"baseUrl": "js",
"paths": {
"jquery":"libs/jquery-1.8.2",
"underscore":"libs/underscore-min",
"backbone":"libs/backbone-min",
},
shim: {
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'underscore': {
exports: '_'
}
} // end Shim Configuration
});

require(['jquery', 'underscore','backbone'], function($, _, Backbone){
console.log('require init - ' + Backbone + ", " + _);

});

最佳答案

尝试使用underscore-amd版本。这是我的要求配置,效果很好:

require.config({
paths: {
"handlebars": "./libs/handlebars/handlebars",
"jquery": "./libs/jquery/jquery",
"underscore": "./libs/underscore-amd/underscore",
"backbone": "./libs/backbone-amd/backbone"
},

shim: {
"backbone": {
exports: "backbone"
},

"Handlebars": {
exports:"Handlebars"
},

"underscore": {
exports: "_"
}
}
});

如您所见,我没有基本 url 和依赖项 - require 将通过提供的路径查找依赖项。

关于jquery - requirejs - 下划线模块未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20113901/

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