2011-08-25 80 views

回答

3

截至今天(0.5.3版本)骨架沒有爲此做好準備在它的自我,但它可以做到:

你需要把你的腳本標記請求underscore.jsbackbone.js第一/早中您的script標記,並在underscore,backbone腳本和其餘腳本加載之間的腳本中執行_.noConflict()。這裏有一個示意圖版本:

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Labbo</title> 
    <script src="underscore.js"></script> 
    <script src="backbone.js"></script> 
    <script> 
     var underscore = _.noConflict(); 
    </script> 

    <script> 
     // In it's own script tag for readability 
     console.log('_ object: ', _); 
     console.log('"underscore" object: ', underscore); 
     var m = new Backbone.Model({}); 
     console.log('Dummy backbone model: ', m); 
    </script> 

    <!-- Load your other scripts. From here on the '_' global isn't defined --> 
    <!-- any more. --> 
    <!-- <script src="your_other_scripts.js"></script> --> 
    </head> 

    <body> 
    Open Developer Tools/Firebug and check the output in the console. 
    </body> 
</html> 

(無法把這個的jsfiddle怎麼一回事,因爲演示需要excactly控制在腳本標籤去)。

+0

謝謝你。是的,這絕對不是問題。只要在包含下劃線和jQuery之後包含主幹,並且在加載這些腳本之間不要添加noConflict()就沒有問題。 – Matt