本文介绍了RequireJS插件(order.js)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近下载了需要。 js 2.0,我的控制台出错:

I recently downloaded require.js 2.0 and I am getting error in my console:

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'

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

Is order.js plugin still supported by requirejs? I don't see its documentation in the website.

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

When I try to remove the file the script breaks.

在我的索引文件中,我在head部分包含了requirejs脚本:

In my index file, I included requirejs script in the head section:

<!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文件中:

Then in my main.js file:

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,当我输入代码时,它有与上面提到的相同的错误。

I sees to it that App.initialize doesn't have any errors and what App.initialize is doing is just simple geo location. The requirejs simply ask for order.js, and when I put the code it's having the same error as mentioned above.

谢谢!

推荐答案

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

Your assumption that order is no longer supported is correct. It was removed in favour of the shim configuration option:

需要2.0升级说明 -

Require 2.0 upgrade notes - https://github.com/jrburke/requirejs/wiki/Upgrading-to-RequireJS-2.0

另外,检查垫片 RequireJS网站上的文档 -

Also, check the shim documentation on the RequireJS site - http://requirejs.org/docs/api.html#config-shim

这篇关于RequireJS插件(order.js)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 22:07