RequireJS插件(order.js)

Jos*_*ito 8 javascript requirejs

http://requirejs.org/

我最近下载了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'
Run Code Online (Sandbox Code Playgroud)

requirejs是否仍然支持order.js插件?我没有在网站上看到它的文档.

当我尝试删除文件时,脚本会中断.

在我的索引文件中,我在head部分包含了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>
Run Code Online (Sandbox Code Playgroud)

然后在我的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();
        });
    }
);
Run Code Online (Sandbox Code Playgroud)

我认为App.initialize没有任何错误,App.initialize正在做的只是简单的地理位置.requirejs只是询问order.js,当我把代码放入时,它具有与上面提到的相同的错误.

谢谢!

Sim*_*ith 17

order不再支持的假设是正确的.它被删除,以支持shim配置选项:

因此,订单插件已被删除,并且分别使用Tim Branyen和Dave Geddes,使用和包装,requirejs 2.0直接在requirejs中集成了这种依赖树规范.

需要2.0升级说明 - https://github.com/jrburke/requirejs/wiki/Upgrading-to-RequireJS-2.0

另外,请查看shimRequireJS站点上的文档 - http://requirejs.org/docs/api.html#config-shim