如果我在没有“namespace: 'foo'”标志的情况下运行优化器,一切都会按预期工作。当我将“namespace: 'foo'”添加到 app.build.js 中时,出现此错误:
GET: file:// (path to the project) /require-jquery/jquery-require-sample/webapp/jquery.js
main-built.js:main-built.js:1839Uncaught Error: Script error http://requirejs.org/docs/errors.html#scripterror
main-built.js:163
我已经四处寻找解决方案,但关于使用 RequireJS 优化器使用 jquery 和命名空间导出单个文件的信息很少。谢谢!
我已经放置了 RequireJS + jQuery 示例项目(带有修改后的 app.build.js 和 app.html)on github here.
({
baseUrl: ".",
out: 'main-built.js',
//Comment out the optimize line if you want
//the code minified by UglifyJS
optimize: "none",
paths: {
"jquery": "require-jquery"
},
name: 'main',
namespace: 'foo'
})
最佳答案
尝试删除名称参数(除非您确实需要它)。
关于jquery - RequireJS + jQuery 命名空间问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13847344/