所以我是 requirejs 和骨干的菜鸟,但我试图在我的本地机器上加载 blueimp 文件上传器的所有依赖项,而不是加载任何外部脚本。这是我的 config.js 文件:
// Set the require.js configuration for your application.
require.config({
// Initialize the application with the main application file.
deps: ["main"],
paths: {
// JavaScript folders.
libs: "../assets/js/libs",
plugins: "../assets/js/plugins",
vendor: "../assets/vendor",
api : "../assets/js/libs/api",
// Libraries.
jquery: "../assets/js/libs/jquery",
jqueryui: "../assets/js/libs/jquery-ui",
lodash: "../assets/js/libs/lodash",
backbone: "../assets/js/libs/backbone",
handlebars: "../assets/js/libs/handlebars",
bootstrap : "../assets/js/libs/bootstrap",
jqueryuiwidget : '../assets/js/libs/jquery.ui.widget',
jstemplates : '../assets/js/libs/tmpl.min',
jsloadimage : '../assets/js/libs/load-image.min',
jscanvastoblob : '../assets/js/libs/canvas-to-blob.min',
iframetransport : '../assets/js/libs/jquery.iframe-transport',
fileupload : '../assets/js/libs/jquery.fileupload',
fileuploadfp : '../assets/js/libs/jquery.fileupload-fp',
fileuploadui : '../assets/js/libs/jquery.fileupload-ui'
},
shim: {
// Backbone library depends on lodash and jQuery.
backbone: {
deps: ["lodash", "jquery", "jqueryui", "api", 'jqueryuiwidget', 'jstemplates', 'jsloadimage', 'jscanvastoblob', 'iframetransport', 'fileupload', 'fileuploadfp', 'fileuploadui'],
exports: "Backbone"
},
handlebars : {
attach: "Handlebars"
},
api : {
attach : "api"
},
bootstrap: {
deps: ["jquery"]
},
// Backbone.LayoutManager depends on Backbone.
"plugins/backbone.layoutmanager": ["backbone"]
}
});
我知道我不应该将所有其他文件作为主干的依赖项,但我只是想加载这些东西。
发生的情况是,它加载时没有任何错误,但是当我查看页面时,它只加载了 canvas-to-blob.min.js、load-image.min.js 和 tmpl.min.js。
任何想法为什么会这样?这很奇怪,因为例如,如果我将其他文件之一上的路径更改为错误,则该事物将抛出错误并失败,就好像它试图加载它一样。但是当它的路径正确时,它就不会加载......