我对requirejs 2.0感到困惑。在我使用!order标签之前,但现在javascripts没有按顺序加载(除非我运行优化)。显然,删除了orderjs支持
如果我有5个脚本,并且我需要按顺序加载前三个脚本,我将如何将其与shim
一起使用?
在我做之前
require([
"order!libraries/file1",
"order!libraries/file2",
"order!includes/file3",
"libraries/file4",
"libraries/file5"
],
function(){
console.log("All done. Everything loaded. Now we can start the app");
});
我现在如何将此翻译为requirejs 2?
答案 0 :(得分:2)
require.config({
paths: {
file1: 'libraries/file1',
file2: 'libraries/file2',
file3: 'libraries/file3',
file4: 'libraries/file4',
file5: 'libraries/file5'
},
shim: {
'file2': ['file1'],
'file3': ['file2']
}
});
require([
"file1",
"file2",
"file3",
"file4",
"file5"
],
function(){
console.log("All done. Everything loaded. Now we can start the app");
});