我正在使用requireJS和ilighbox脚本。 灯箱有4个必需的文件可供使用。 现在我有这样的代码:
require.config({
baseUrl: "/js/",
paths: {
jquery: "libs/jquery/jquery-1.11.1.min",
jqueryAnimationFrame: "libs/ilightbox/js/jquery.requestAnimationFrame",
jqueryMouseWheel: "libs/ilightbox/js/jquery.mousewheel",
ilightbox:"libs/ilightbox/js/ilightbox.packed"
}
});
我可以像shim一样使用依赖吗? 例如:
require.config({
baseUrl: "/js/",
paths: {
jquery: "libs/jquery/jquery-1.11.1.min",
ilightbox:{
"libs/ilightbox/js/ilightbox.packed":
deps: [
'jquery',
"libs/ilightbox/js/jquery.requestAnimationFrame",
"libs/ilightbox/js/jquery.mousewheel"
]
}
}
});
答案 0 :(得分:0)
您可以使用填充程序 - 但它们基于包,而不是路径:
require.config({
baseUrl: '../',
paths: {
'jquery': 'lib/jquery-1.7.2',
'underscore': 'lib/underscore',
'backbone': 'lib/backbone',
'console': 'lib/console'
},
shim: {
jquery: {
exports: '$'
},
underscore: {
exports: '_'
},
backbone: {
deps: ["underscore", "jquery"],
exports: "Backbone"
},
console: {
exports: "console"
}
}
});