2

我对requirejs 2.0感到困惑。在我使用 !order 标签之前,但现在 javascript 没有按顺序加载(除非我运行优化)。显然 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?

4

1 回答 1

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");
});
于 2012-10-08T17:33:10.130 回答