2012-10-08 71 views
2

我對requirejs 2.0感到困惑。在我使用!order標籤之前,現在javascripts不按順序加載(除非我運行優化)。顯然這個orderjs支持被刪除了requirejs按順序加載內容

如果我有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

http://stackoverflow.com/a/10842492/1217408 – TheZ

回答

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"); 
});