0

I am using RequireJS 2.0.2

I have the following in a file used as the entry point.

require({

    "packages"  : ['bi/charts'],
    baseurl     : '/js/',
    paths       : {
        handlebars  : "lib/handlebars-1.0.0.beta.6",
        jquery      : "lib/jquery-1.7.2.min",
        underscore  : "lib/underscore-1.3.3.min",
        modernizr   : "lib/modernizr-custom.2.5.3.min",
        BI          : "bi/BIf"
    }
});

however it only recognises 'jquery' and none of the other paths, it comes back with the following error:

NetworkError: 404 Not Found - [link]http://localhost:62033/js/handlebars.js"
handlebars.js
Script error http://requirejs.org/docs/errors.html#scripterror
[Break On This Error]   

var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);

....thoughts?

Many thanks.

4

1 回答 1

2

您可能需要在要求之前调用配置。还要注意在路径中添加斜线。利用:

"handlebars" : "/lib/handlebars"

不是

"handlebars" : "lib/handlebars"


  require.config({
    baseUrl: "/js/",
    paths: {
        "handlebars": "/lib/handlebars"
    },
  });
  require( ["handlebars"],
    function(handlebars, myModule) {
    }
  );

另请参阅配置路径

于 2012-06-28T14:09:54.083 回答