我是Require.js新手,我看到API文档使用了require和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'
}
});要求使用:
require.config({
paths: {
foo: 'libs/foo-1.1.3'
}
});发布于 2014-09-29 11:23:15
加载RequireJS时,它会在全局空间中导出相同对象的符号requirejs和require。
当您在模块中时,require和requirejs不一定是同一个对象。考虑一下这个测试:
define(function (require, exports, module) {
console.log(require === requirejs);
});输出到控制台的值通常为false。(我记得读过RequireJS的代码时,它总是错误的,但我可能记错了。)
https://stackoverflow.com/questions/26063878
复制相似问题