2013-03-02 61 views
0

我剛剛下載了arian/Mootool並簽出了1.5amd分支。我已經建立了一個簡單的項目並且需要Element模塊。出於某種原因,它出現在dom中,但在源代碼中未定義。要求Mootools AMD模塊

define(function(require) { 

    domReady = require('require/domReady'); 
    Element = require('mootools/Element/Element'); 

    domReady(function() { 
     console.log Element // undefined 
    }); 

}); 

任何想法如何或爲什麼會發生?

這可能是讓你知道,我使用RequireJS 2.1.4

感謝

回答

0

首先,我認爲阿里安的mootools-amd是,是那種拋棄,不應該被實際使用的實驗。 mootools 2(aka Prime)是用CommonJS編寫的,可以用wrapup轉換成AMD包裝。

秒,你需要在你的外部函數運行之前需要的東西,否則 - 不能保證當你引用它時,元素將被解析。

這樣:

define([ 
    'require/domReady', 
    'mootools/Element/Element 
'], function(domReady, Element){ 
    Element; 
}); 
+0

嗯。我不知道阿里安的遺體被遺棄了。我想我會繼續前進。 – Pardoner 2013-03-04 22:44:31