2012-05-31 10 views
8

http://requirejs.org/RequireJS प्लगइन (order.js)

मैं हाल ही में require.js 2.0 डाउनलोड किया है और मैं अपने कंसोल में त्रुटि हो रही है:

Uncaught TypeError: Object function(){var g=ga.call(arguments,0),e;if(f&&v(e=g[g.length-1]))e.__requireJsBuild=!0;g.push(d);return b.apply(null,g)} has no method 'nameToUrl' 

order.js प्लगइन अभी भी requirejs द्वारा समर्थित है? मुझे वेबसाइट में इसका दस्तावेज नहीं दिख रहा है।

जब मैं फ़ाइल को हटाने की कोशिश करता हूं तो स्क्रिप्ट टूट जाती है।

<!DOCTYPE html> 
<html> 
    <head> 
     <title> 
      My Mobile Application 
     </title> 
     <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" /> 
     <link rel="stylesheet" href="public/css/style.css" /> 
     <script data-main="scripts/main.js" src="scripts/require.js"></script> 
    </head> 
    <body></body> 
</html> 
तब मेरे main.js फ़ाइल में

:

मेरी इंडेक्स फ़ाइल में, मैं शीर्ष अनुभाग में requirejs स्क्रिप्ट शामिल

requirejs.config({ 
    //By default load any module IDs from js/lib 
    baseUrl: 'js/lib', 
    //except, if the module ID starts with "app", 
    //load it from the js/app directory. paths 
    //config is relative to the baseUrl, and 
    //never includes a ".js" extension since 
    //the paths config could be for a directory. 
    paths: { 
     app: '../app', 
     assets: '../assets', 
     views: '../app/views', 
     templates: '../app/templates', 
     collections: '../app/collections', 
     models: '../app/models' 
    } 
}); 

// Start the main app logic. 
requirejs([ 
    'jquery/jquery', 
    'assets/jqm.config', 
    'jquery/mobile', 
    'text' 
]); 

require([ 
    'app' 
    ], 
    function(App){ 
     $(document).ready(function(){ 
      App.initialize(); 
     }); 
    } 
); 

मैं इसे करने के लिए देखता है कि App.initialize नहीं करता ' टी में कोई त्रुटि नहीं है और App.initialize क्या कर रहा है बस सरल भौगोलिक स्थान है। Requjs बस order.js के लिए पूछते हैं, और जब मैं कोड डालता हूं तो ऊपर वर्णित वही त्रुटि होती है।

धन्यवाद!

+3

[स्टैक ओवरफ़्लो एक मन रीडर नहीं है] (http://meta.stackexchange.com/a/128551/177538)। कोड क्या है? – Joseph

+1

इसके बारे में क्षमा करें। संपादित। :) –

उत्तर

17

आपकी धारणा है कि order अब समर्थित नहीं है सही है। यह shim विन्यास विकल्प के पक्ष में हटा दिया गया था:

So, the the order plugin has been removed and following the lead of Tim Branyen and Dave Geddes, of use and wrap respectively, requirejs 2.0 integrates that kind of dependency tree specification directly in requirejs.

आवश्यकता होती है 2.0 उन्नयन नोट - http://requirejs.org/docs/api.html#config-shim

+0

ठीक है बहुत बहुत धन्यवाद, यह वास्तव में एक बड़ी मदद थी। अब इसे आज़माएं और यह बताएं कि यह काम कर रहा है :) –

+0

मैं जिस तरह से jQuery का उपयोग कर रहा हूं और पहले मैंने डाउनलोड किया [लिंक] (http://requirejs.org/docs/download.html#samplejquery) से एक फ़ाइल दिए गए लिंक, मैंने requ.js के बजाय इसकी आवश्यकता-jquery.js का उपयोग किया, अब मुझे यह त्रुटि मिल रही है: प्लगइन अपरिभाषित है। प्रकार की त्रुटियों को डीबग करना बहुत मुश्किल है। –

+0

क्रोम के निरीक्षण तत्व में, मुझे यह त्रुटि मिल रही है: अपरिभाषित संपत्ति 'सामान्यीकृत' नहीं पढ़ सकता। Sigh * –

2

ओह यह सोचा बाहर - https://github.com/jrburke/requirejs/wiki/Upgrading-to-RequireJS-2.0

इसके अलावा, RequireJS साइट पर shim प्रलेखन की जाँच करें।

//This is our main applicatoon boot loader or bootstrap 
//here we are loading necessary scripts dependencies like 
//jquery, jqm.config, mobile, text 


requirejs.config({ 
    baseUrl: 'js/libs', 
    //except, if the module ID starts with "app", 
    //load it from the js/app directory. paths 
    //config is relative to the baseUrl, and 
    //never includes a ".js" extension since 
    //the paths config could be for a directory. 
    paths: { 
     app: '../app', 
     assets: '../assets', 
     views: '../app/views', 
     templates: '../app/templates', 
     collections: '../app/collections', 
     models: '../app/models' 
    } 
}); 

// Start the main app logic. 

require(["jquery","assets/jqm.config","jquery/mobile","text","app"], 
    function(
    $, 
    config, 
    mobile, 
    text, 
    App 
    ) { 
    //the jquery.alpha.js and jquery.beta.js plugins have been loaded. 
    $(function() { 
     App.initialize(); 
    }); 
}); 
संबंधित मुद्दे