2012-12-24 35 views
5

我試圖初始化一個應用程序,但似乎無法讓紙張js正確加載到我的腳本。我使用require.js作爲我的AMD加載器,並試圖用填充模塊加載紙張js。Paper.js填充配置Require.js

這裏是我的代碼:

requirejs.config({ 
    urlArgs: "bust=" + (new Date()).getTime(),//used to keep the browser from caching the scripts as we move 
    baseUrl : "scripts",//base scripts page! 
    paths : { 
     'jquery' : "../components/jquery/jquery.min", //specific libraries -- can be specified later 
     'underscore' : "../components/underscore/underscore", 
     'paper' : "../components/paper/paper" 
    }, 
    shim: { 
     'underscore': { 
      exports: '_' 
     }, 
     'paper' : { 
      exports: 'Paper' 
     }, 
    }, 
}); 

// initialize the document with a doc ready! 

requirejs(["jquery", "underscore", "paper"], function ($, _, Paper) { 
    alert(_); 
    alert(Paper); 
}); 

第一個提醒工作正常,(下劃線),這意味着它加載好了,但我似乎無法弄清楚如何獲得paper.js正常工作。

任何幫助將不勝感激。

+0

第一步:檢查您的javascript控制檯以確保組件/紙張/紙張正在加載。 –

+1

在圖書館窺探之後,它不應該是'PaperScript'而不是'Paper'嗎? – asgoth

+0

嘿,它看起來像一切正在加載,但我需要把它包裝在一個定義模塊 – JonMorehouse

回答

2

PaperJS全局名稱空間是「紙」。

只需將「Paper」替換爲「paper」即可使用。

'paper' : { 
    exports: 'paper' 
} 
+0

工作得很好,我在一週前做了這個!這兩個圖書館在一起很好地工作。 – JonMorehouse