2012-05-31 5 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? Я не вижу его документации на веб-сайте.

Когда я пытаюсь удалить файл, скрипт ломается.

В моем индексном файле, я включил 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.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 Безразлично» t есть какие-либо ошибки, и то, что делает App.initialize, - простое гео-местоположение. Запросы просто запрашивают 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 нот обновления - https://github.com/jrburke/requirejs/wiki/Upgrading-to-RequireJS-2.0

Кроме того, проверьте shim документации на сайте RequireJS - http://requirejs.org/docs/api.html#config-shim

+0

Хорошо, спасибо большое, это была отличная помощь. Попробуем сейчас и дам вам знать, если он работает :) –

+0

Я использую jQuery, кстати, и ранее я загрузил [link] (http://requirejs.org/docs/download.html#samplejquery) файл из данная ссылка, я использовал ее require-jquery.js вместо require.js, теперь я получаю эту ошибку: плагин не определен. Его очень сложно отладить ошибки типов. –

+0

В элементе проверки chrome я получаю эту ошибку: не могу прочитать свойство «normalize» undefined. Sigh * –

2

О фигурировал его.

//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(); 
    }); 
}); 
Смежные вопросы