2012-05-31 2 views
8

http://requirejs.org/RequireJS 플러그인 (order.js)

나는 최근 2.0 require.js 다운로드 내 콘솔에서 오류가 점점 오전 :

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에서 지원

? 웹 사이트에 설명서가 표시되지 않습니다.

파일을 제거하려고하면 스크립트가 중단됩니다. 내 main.js 파일에서 다음

<!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> 

: 내 인덱스 파일에서

, 나는 머리 부분에 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가 수행하는 작업은 단순한 지리적 위치입니다. requirejs는 단순히 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를 사용하고 있습니다. 이전에 [link] (http://requirejs.org/docs/download.html#samplejquery)에서 파일을 다운로드했습니다. 주어진 링크, require.js 대신 require-jquery.js를 사용했습니다. 이제이 오류가 발생합니다 : 플러그인은 정의되지 않았습니다. 종류 오류를 디버그하는 것은 매우 어렵습니다. –

+0

크롬의 검사 요소에서이 오류가 나타납니다 : 정의되지 않은 'normalize'속성을 읽을 수 없습니다. 한숨 * –

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(); 
    }); 
}); 
관련 문제